I’ve been doing a lot of converting of web pages that required the user to refresh the page for updated content to AJAX (eliminates need to refresh). It was all good until I started receiving complaints that data was no longer refreshing in IE.
What I’m using is a AJAX get command like this:
xmlhttp.open(“GET”,”url”,true);
xmlhttp.send();
however, in Internet Explorer, the content never gets refreshed – that is, the AJAX request is getting cached. There are a number of suggested solutions, including using a POST rather than a GET and appending a random string to the request.
The best way to keep AJAX working in IE is to tell the xmlhttp object not to cache content that is older than a certain date; you can do that by changing the request in this fashion (appending 1 line):
xmlhttp.open(“GET”,”url”,true);
xmlhttp.setRequestHeader(“If-Modified-Since”, “Sat, 1 Jan 2000 00:00:00 GMT”);
xmlhttp.send();
This will solve any AJAX caching problem you might encounter. It’s a simple solution, but caused me a big headache!
Also, if you have webpages with ad code on them, each refresh is another impression and can skew your results more than you think! Move to AJAX and you’ll solve that problem :)
I hope this helps those of you playing with AJAX.
Thanks a lot. It helped me a lot
Thank you so much!
Thank you, problem solved!
Thanks. Your big headache reduced mine.
Thanks so much for letting us know how to fix this!
Ummm…why not set cache-control in the response header? The following should work very nicely Cache-Control: no-cache
Thanks a bunch pal !!!
Thanks you so much, Solved my prob…..
Thank you !!
Thank you
Brilliant, Thank you!
Thanx a mill. it works :)
Glad I could help Mark and Dillen :)
Jim
THANK YOU!
Thanks, I’ve been searching for this for a very long time, thanks for your help.