0

I have a BIG issue. I am creating an application completely made in Ajax, jQuery 1.3.2 + PHP. Everything works just fine in every browser. But IE keeps using the temporary files and does not show the changes made by the javascript and jQuery codes until I manually delete the temporary files! This is incredible!! How can I solve this issue? Please help me! IE will drive me crazy! Thank you

DiegoP.
  • 45,177
  • 34
  • 89
  • 107
  • Browsers are *expected* to cache HTTP responses unless the server demands otherwise. See http://www.fiddler2.com/redir/?id=httpperf and http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx – EricLaw May 18 '11 at 04:23

2 Answers2

1

In my brief look I didn't see a duplicate of this, but I expect there is one.

But this is good:

how to clear the cache data when using ajax?

When you return your request use this header:

<?php header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");  

And when you make your request you can use this:

var url="UI/RoomDetailsView.jsp?ignoreMe=" + new Date().getTime();

Basically, turn off caching from the server and add a parameter that varies so the server will see something different and not use the cached version.

Community
  • 1
  • 1
James Black
  • 41,583
  • 10
  • 86
  • 166
  • You should not send post-check or pre-check; they don't do what you think. Using no-cache alone will be plenty. http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx – EricLaw May 18 '11 at 04:22
1

jQuery has a global setting that will get around caching by attaching a random string to the end of each AJAX request. Since the file names are now random no cached version can ever be called. Insert the following on any page and your caching issues should be resolved.

$.ajaxSetup ({
    cache: false
});
Mr.Wizard
  • 24,179
  • 5
  • 44
  • 125