gpt4 book ai didi

javascript - Chrome 是否违反缓存标准?

转载 作者:数据小太阳 更新时间:2023-10-29 04:18:03 26 4
gpt4 key购买 nike

我们注意到 Chrome 会在本地缓存文件,甚至不会向我们的服务器发送请求来检查是否有更新版本的 javascript 文件。

Google 缓存的 js 文件的 HTTP 响应 header 示例:

Accept-Ranges:bytes
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Content-Encoding:gzip
Content-Length:5479
Content-Type:application/javascript
Date:Tue, 12 Jan 2016 22:46:07 GMT
ETag:"7d68e1ceb647d11:0"
Last-Modified:Tue, 05 Jan 2016 12:44:25 GMT
Server:Microsoft-IIS/8.5
Vary:Accept-Encoding
x-robots-tag:noindex

Chrome 缓存文件是否有效?没有 Cache-control header 或声明文件可以在本地缓存的东西,它只有 ETag 和 Last-Modified。


顺便说一下

有没有办法(也许是 header )指示 Chrome 检查缓存文件是否已更改而不将版本附加到文件名?设置无缓存不是一个选项,因为我确实希望它被缓存,但我想按应有的方式使用 ETag 和 Last-Modified header 。

最佳答案

Unless specifically constrained by a cache-control (section 14.9) directive, a caching system MAY always store a successful response (see section 13.8) as a cache entry, MAY return it without validation if it is fresh, and MAY return it after successful validation.

您始终可以使用 must-revalidate 指令。

When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to a subsequent request without first revalidating it with the origin server.

Source

关于javascript - Chrome 是否违反缓存标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34761700/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com