[jQuery] How to Disable Caching for $.ajax GET

Tadashi Shigeoka ·  Thu, January 9, 2014

I’ll introduce how to configure jQuery Ajax GET to not cache.

IE by default has ajax GET cache: true, so it doesn’t send requests to the server from the second time onward.

So it’s good to explicitly set cache: false.

$.ajax({
  type: 'GET',
  dataType: 'json',
  url : "http://example.com/",
  cache : false,
  ...
});

There’s also a method to always disable caching.

If you add code that sets cache: false in $.ajaxSetup to common JavaScript processing, ajax GET will process with cache: false by default.

$(function() {
  $.ajaxSetup({
    cache: false
  });
});

I suffered because ajax GET results were cached in IE11 and it wasn’t working properly…

Reference Information

That’s all from the Gemba.