Home » AJAX

Internet Explorer cache and AJAX

10 February 2009 One Comment

The cache in Internet Explorer is not very AJAX friendly for GET/POST commands. You must put in a constantly changing variable in the URL such as date with seconds in Internet Explorer. I noticed this when the refresh of my GET command would only work once in my window.setInterval(.. , .. ) function.  However, in Mozilla and Safari, my function was working perfect.

The solution to this is to append the current date and time into the URL of your GET/POST request. Special thanks to this post.

...

var requeststring = "http://........."+"&requesttime=" + new Date().getTime();
myHttpObject.open("GET",requeststring,true);

...

 

I previously tried setting the cache to expire on the PHP header files, but it has no effect. However, this date/time trick works.

One Comment »

  • gyrolistic said:

    All the more reason why IE (should just die …)

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.