IE6 and Caching

2019-04-01 13:12发布

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?

6条回答
走好不送
2楼-- · 2019-04-01 13:40

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.

查看更多
聊天终结者
4楼-- · 2019-04-01 13:46

Content with "Content-Encoding: gzip" Is Always Cached Although You Use "Cache-Control: no-cache"

http://support.microsoft.com/kb/321722

You could also disable gzip just for IE6

查看更多
我只想做你的唯一
5楼-- · 2019-04-01 13:54

Cache-Control: private, max-age=0 should fix it. From classic ASP this is done with Response.Expires=-1.

Keep in mind when testing that just because your server is serving pages with caching turned off doesn't mean that the browser will obey that when it has an old cached page that it was told was okay to cache. Clear the cache or use F5 to force that page to be reloaded.

Also, for those cases where the server is serving cached content it you can use Ctrl+F5 to signal the server not to serve it from cache.

查看更多
小情绪 Triste *
6楼-- · 2019-04-01 13:54

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

查看更多
淡お忘
7楼-- · 2019-04-01 14:03

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.

查看更多
登录 后发表回答