AJAX IE Issues
17 November 2011Have you been trying to move your website to being AJAX based but had issues with certain browsers/configurations? Such as IE and your data does not update?
Internet Explorer is well known for the ultimate caching technique, assuming that any developer/server has no knowledge of caching settings and forcing the browser to indefinitely cache all requests. If you are requesting a file with dynamic data, you are most likely to fall foul of this IE caching technique. IE disregards all caching headers; so even setting your headers as no-cache; re-validate will not work. The issue can be resolved in two ways.
First if you add additional parameters to your get request; making the url different then the previous call would trigger IE to fetch the new url.
Or else by issuing a POST instead of a GET. POST requests are never cached by any browser these are far safer when fresh data is required every time.
How to detect if you have the above AJAX IE issue?
Make sure that the AJAX request runs the first time; by having updated values at least once.
Make sure that other browsers are getting data. This can be verified using the Net/Network tab on firebug or chrome developer tools.
Check your log files and confirm that there are no multiple requests from the same ip from IE
This bug effects all versions of IE from IE6 up to EI9. To resolve an issue on one of my client's websites I had to switch the request type to post as explained above. If using jQuery you can replce $.get with $.post and you should be ready to go.
For performance reasons one might want to leave AJAX requests to get if they return static content that does not change. This ensures that browsers use a cached version to give an impression of better speed. For dynamic data however it is suggested to switch to POST.