Jump to content
MakeWebGames

How to fix IE Caching AJAX pages.


Will

Recommended Posts

Just thought I'll share this with you because it took me ages to realize why it happened.

I was using AJAX to do some form stuff when the use clicked a button, but it only worked the first time I spent ages thinking it was me but then I found an article on the Internet saying the IE caches the pages.

To fix this just put this at the end of the URL you are calling in the javascript:

 

+ "&ms=" + new Date().getTime();

I'm sure you can guess that this makes the URL different every time so IE can't cache it.

Link to comment
Share on other sites

  • 1 year later...

Re: How to fix IE Caching AJAX pages.

The following block of headers, placed in any dynamic page before a response has been sent to the user, will give you the same effect without messing with your query strings (the first two help with SEO as well).

 

header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header ('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
header ('Pragma: no-cache'); // HTTP/1.0
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...