How to prevent a jQuery Ajax request from caching in Internet Explorer?

SABU picture SABU · Nov 29, 2010 · Viewed 157.4k times · Source

How do I prevent a jQuery Ajax request from caching in Internet Explorer?

Answer

Nick Craver picture Nick Craver · Nov 29, 2010

You can disable caching globally using $.ajaxSetup(), for example:

$.ajaxSetup({ cache: false });

This appends a timestamp to the querystring when making the request. To turn cache off for a particular $.ajax() call, set cache: false on it locally, like this:

$.ajax({
  cache: false,
  //other options...
});