Windows 7 上的 IE11 不缓存文件

IE11 on Windows 7 does not cache files

在检查我们网站上的缓存行为时,我得到了一个非常令人困惑的结果 - 我的 Internet Explorer 11 浏览器根本没有缓存任何文件。 Internet选项中的缓存设置设置为"Check for newer versions of stored pages: Automatically".

使用 IE 开发人员工具进一步调查,所有文件都在没有 "if-modified-since" HTTP header 的情况下请求,这当然导致服务器 return 完整文件的状态结果为 200 .预期的行为是 IE 应该发送 "if-modified-since" header,然后服务器以 304(未修改)状态响应,告诉浏览器使用缓存的副本。

我尝试过的所有网站都会出现同样的行为。

然后我使用 browserstack.com 在 Windows 7 机上打开远程 IE11。同样的结果,没有文件被缓存。但是,在 Windows 8.1 机器上,IE11 缓存文件并发送 "if-modified-since" header,导致 304 响应。

我包括示例请求和响应 headers:

请求来自 Windows 7 / IE11:

Request:GET /EdUwb.png HTTP/1.1
Accept:image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5
Referer:http://whosebug.com/
Accept-Language:sv-SE
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding:gzip, deflate
Host:i.stack.imgur.com
Connection:Keep-Alive

来自 Windows 7 / IE11 的响应:

Response:HTTP/1.1 200 OK
Date:Wed, 05 Aug 2015 14:30:43 GMT
Content-Type:image/png
Content-Length:3635
Connection:keep-alive
Set-Cookie:__cfduid=dfbb24e8f5badb07e8f2bbd969590320b1438785043; expires=Thu, 04-Aug-16 14:30:43 GMT; path=/; domain=.imgur.com; HttpOnly
Cache-Control:public, max-age=315360000
ETag:"c5d00c1be2583713eca1d0ad1efdb914"
Expires:Sat, 02 Aug 2025 14:30:43 GMT
Last-Modified:Thu, 02 Apr 2015 19:36:41 GMT
x-amz-version-id:Rmrsr2WfDsdFppBa_Ju10BC3Y52.bglA
CF-Cache-Status:HIT
Vary:Accept-Encoding
Server:cloudflare-nginx
CF-RAY:2113339ae74b0a48-ARN

来自 Windows 8.1 / IE11 的请求:

Request:GET /EdUwb.png HTTP/1.1
Accept:image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5
Referer:http://whosebug.com/
Accept-Language:en-US
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding:gzip, deflate
Host:i.stack.imgur.com
If-Modified-Since:Thu, 02 Apr 2015 19:36:41 GMT
If-None-Match:"c5d00c1be2583713eca1d0ad1efdb914"
Connection:Keep-Alive

来自 Windows 8.1 / IE11 的响应:

Response:HTTP/1.1 304 Not Modified
Content-Type:image/png
Content-Length:3635
ETag:"c5d00c1be2583713eca1d0ad1efdb914"
x-amz-version-id:Rmrsr2WfDsdFppBa_Ju10BC3Y52.bglA
CF-Cache-Status:HIT
Vary:Accept-Encoding
CF-RAY:21133083e7920c5f-AMS
Expires:Sat, 02 Aug 2025 14:28:19 GMT
Last-Modified:Thu, 02 Apr 2015 19:36:41 GMT

有没有人知道为什么文件没有缓存在 Windows 7 上?

IE11 devtools 有一个默认启用的 "Always refresh from server" 选项。你必须关闭它才能在开发工具中看到缓存。

在 IE 中取消选择以下设置:

Internet 选项 > 高级选项卡 > 设置 > 安全 > 关闭浏览器时清空 Internet 临时文件夹。

访问此处了解更多信息:http://muthukumarsankaralingam.blogspot.com/2018/08/configure-internet-explorer-to-read.html