Nifty jQuery tricks - Avoid Cache

Categories

JavaScript

I found this two function yesterday while working on one of our applications.

We are turning a very boring page into a full blown jQuery powered page. It’s got loads of functionalities being turned into Ajax calls to give the user a better experience. We are really taking usability into account, and minimizing things like page refresh or reloads is essential.

One thing that got to us, was the fact that IE8 insists in caching some Ajax contents when loading things too quickly (i.e. if a link is clicked, and a tab is clicked subsequently).

This is easily fixable by adding a timestamp to the request, so whenever a link is clicked, the request would be doing something like: