views:

970

answers:

5
+1  Q: 

IE6 and Caching

It seems that IE6 ignores any form of cache invalidation sent via http headers, I've tried setting Pragma to No Cache and setting Cache Expiration to the current time, yet in IE6, hitting back will always pull up a cached version of a page I am working on.

Is there a specific HTTP Header that IE6 does listen too?

A: 

Have you tried setting an ETag in the header? They're a pretty reliable way to indicate that content has changed w3c Spec & Wikipedia

Beyond that, a little more crude way is to append a random query string parameter to the request, such as the current unix timestamp. As I said, crude, but then IE6 is not the most subtle of beasts

iAn
+5  A: 
Hafthor
F5 causes Pragma: no-cache to be added to the request headers. Ctrl-F5 in addition to this header suppress the if-modified-since and if-none-match headers therefore removing the origins servers option to send a 304 Not Modified response. Cache-Control is not sent in a request header.
AnthonyWJones
A: 

A little note: By experience I know that IE6 will load Javascript from cache even if forced to reload the page via ctrl-f5. So if you are working on Javascript always empty the cache.

The IE web developer toolbar can help immensely with this. There's a button for clearing the cache.

erlando
A: 

see Question: Making sure a webpage is not cached, across all browsers. http://stackoverflow.com/questions/49547/making-sure-a-webpage-is-not-cached-across-all-browsers#49549 I think this should help out with your problem too.

Edward Wilde
+1  A: 

You must be careful. If you are using AJAX via XMLHttpRequest (XHR), cache "recommendations" set in the header are not respected by ie6.

The fix is to use append a random number to the url queries used in AJAX requests. For example:

http://test.com?nonce=0123

A good generator for this is the UTC() function that returns a unique timestame for the user's browser... that is, unless they mess with their system clock.

thesmart