IE 9+忽略ETag值更改并返回缓存的响应 [英] IE 9+ ignores ETag value change and returns cached response

查看:91
本文介绍了IE 9+忽略ETag值更改并返回缓存的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Etag提供的缓存验证可与FF& amp; chrome,但IE似乎会忽略Etag值,并始终返回缓存的响应。

The Etag provided cache validation that works well with FF & chrome, but IE seems to ignore the Etag value and always returns the cached response.

服务器响应为:

HTTP/1.1 200 OK
Date: Mon, 07 Jul 2014 06:01:57 GMT
Content-Type: application/json
ETag: a7628382056ddd13b7e06991571fd3ad
Content-Encoding: gzip
Content-Length: 4360

当客户端时发送条件获取请求

when client sends a conditional get request

If-None-Match: 71fb49ecd6f85545693dec0e78ae2131

根本不发送请求,IE返回缓存的响应。当ETag值相同时透明,但是当ETag不相同时出现问题。

The request is not sent at all and IE returns the cached response. It transparent when ETag value is the same but a problem when ETag is different.

唯一适用于我的解决方案是添加标头

The only solution that worked for me was adding header

Cache-Control: no-cache

我监视了网络,并迫使IE验证ETag值。

问题已解决!

但是我没有找到解决此问题的任何官方解决方案。我使用了使IE缓存资源,但总是重新验证的帖子作为参考,但是大多数信息与我的问题无关。

I monitored the network and it forces IE to validate the ETag value.
problem is solved!
However I didn't find any official solution for this problem. I used the post Make IE to cache resources but always revalidate as a reference but most of the information was irrelevant to my problem.

如果您有其他想法或建议,请分享

if you have another idea or advise please share

推荐答案

Internet Explorer使用一些启发式方法来缓存响应。您可以在中了解更多信息。 启发式缓存改进部分中Internet Explorer 9的缓存改进

Internet Explorer uses some heuristics for caching responses. You can read more at Caching Improvements in Internet Explorer 9 in the Heuristic Cache Improvements section:


如果最后一个-服务器的响应中没有修改过的标头,
然后Internet Explorer将退回到每浏览器一次
会话重新验证行为。

If a Last-Modified header wasn’t present in the server’s response, then Internet Explorer will fall back to the "Once per browser session" revalidation behavior.

和:


如果响应确实具有最后修改时间,则启发式
从那时起,到期值不应超过间隔
的一部分。这个分数的典型设置可能是10%。

if the response does have a Last-Modified time, the heuristic expiration value SHOULD be no more than some fraction of the interval since that time. A typical setting of this fraction might be 10%.

您想要的是绕过这些试探法,并强制IE使用以下命令重新验证内容:服务器。为此,请检查使IE缓存资源,但始终重新验证及其答案。关键标题似乎是:

What you want is to bypass these heuristics and force IE to revalidate the content with the server. To do so, please check Make IE to cache resources but always revalidate and its answer. The key headers seem to be:

Last-Modified: Wed, 16 Feb 2011 13:52:26 GMT
Expires: -1
Cache-Control: must-revalidate, private

奖金:也请请参阅前面的链接中有关 Vary Improvements 的部分:

Bonus: please also see the section about the Vary Improvements in the earlier link:


如果响应包含指定以下内容的Vary指令如果标头包含
而不是Accept-Encoding,Host或User-Agent(或
的任意组合),则Internet Explorer仍将缓存响应,如果
响应包含ETAG标头。但是,该响应将
视为过期,并且将在
重用之前发出条件HTTP请求,以确定缓存的副本是否有效。

If a response contains a Vary directive that specifies a header other than Accept-Encoding, Host, or User-Agent (or any combination of these) then Internet Explorer will still cache the response if the response contains an ETAG header. However, that response will be treated as stale and a conditional HTTP request will be made before reuse to determine if the cached copy is valid.

虽然没有说明未指定 Vary 标头会发生什么,但值得使用此值(请参见此信息

While it does not say what happens when no Vary header specified, it might be worth playing with this value (see this post)

这篇关于IE 9+忽略ETag值更改并返回缓存的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆