jQuery AJAX Cache Problems on IE
Handling different default AJAX caching definitions between browsers.
Internet Explorer (IE) has this huge need to be different. In my opinion, this have no explanation other than the need to screw some development time :) Here I'll talk about another simple example: AJAX cache.
No other browser, by default, caches AJAX requests... but IE does. So, when you make a second AJAX call with the exact same parameters, IE thinks it's smarter than others and returns the result it has in cache from the first request, and there's no way to make it refresh that cache, not F5, not Ctrl+F5, not even asking politely... nothing!
What we have to do is tell, right on the request, that we don't want the result to be cached. So on a jQuery AJAX request, we would do:
$.ajax(
cache: false,
url: 'http://myurl',
data: {}
);
This will work for this particular request. If you want to expand the scope of this setting to all AJAX requests, you can set it on the global AJAX configuration:
$.ajaxSetup({ cache: false });
From now on, I'll be making this cache setting a "must" on every AJAX call.