IE 10 is caching Ajax responses, returns response code 304

Posted on 19-03-2015 10:36 by graham
You might sometimes notice that you Ajax requests are not working as expected in Internet Explorer 10. Instead of getting the actual response from the server, IE uses the cached response and returns code 304.

There are a few ways to turn off response caching. If you are using JQuery, you can turn off Ajax caching globally:
$.ajaxSetup({
// Disable caching of AJAX responses
cache: false
});

or just for the given request:
$.ajax({
url: "...",
cache: false
});


Another simple trick would be to add the current date as a parameter to the request:
$.get("...", { timestamp: (new Date()).getTime() }, function() {

});
Comments

 

Add comment

Has this tutorial been helpful to you? Or do you see anything wrong? We appreciate your opinion!
Your comment:
Show formatting hints
HTML is disallowed, but in your text you can use the following markup
  • [code][/code] for a block of code
  • [tt][/tt] for inline code
  • [link]link href|link anchor[/link] for links
  • [b][/b] for bold text
Email:
+ Ask a question
If you have a technical question related to programming and computers, ask it here. Other users will help you solve it!
Unanswered questions
Share your knowledge by helping others solve their problems