简体   繁体   English

HTTP缓存控制的最大使用期限,必须重新验证

[英]HTTP Cache Control max-age, must-revalidate

I have a couple of queries related to Cache-Control. 我有几个与Cache-Control相关的查询。

If I specify Cache-Control max-age=3600, must-revalidate for a static html/js/images/css file, with Last Modified Header defined in HTTP header: 如果我指定Cache-Control max-age=3600, must-revalidate对静态html / js / images / css文件max-age=3600, must-revalidate ,并在HTTP标头中定义“ Last Modified Header”:

  1. Does browser/proxy cache(like Squid/Akamai) go all the way to origin server to validate before max-age expires ? 浏览器/代理缓存(如Squid / Akamai)是否在max-age到期之前一直到原始服务器进行验证? Or will it serve content from cache till max-age expires? 还是会从缓存中提供内容直到max-age到期?
  2. After max-age expiry (that is expiry from cache), is there a If-Modified-Since check or is content re-downloaded from origin server w/o If-Modified-Since check? 在最大使用期限(从缓存中到期)之后,是否进行了If-Modified-Since检查,或者是否从源服务器重新下载了内容而不进行If-Modified-Since检查?

a) If the server includes this header: a)如果服务器包含此标头:

Cache-Control "max-age=3600, must-revalidate"

it is telling both client caches and proxy caches that once the content is stale (older than 3600 seconds) they must revalidate at the origin server before they can serve the content. 它告诉客户端缓存和代理缓存,一旦内容过时(早于3600秒),它们必须在原始服务器上重新验证才能提供内容。 This should be the default behavior of caching systems, but the must-revalidate directive makes this requirement unambiguous. 这应该是缓存系统的默认行为,但是must-revalidate指令使此要求明确。

b) The client should revalidate. b)客户应重新验证。 It might revalidate using the If-Match or If-None-Match headers with an ETag, or it might use the If-Modified-Since or If-Unmodified-Since headers with a date. 它可能使用带有ETag的If-MatchIf-None-Match头来重新验证,或者使用带有日期的If-Modified-SinceIf-Unmodified-Since头来重新验证。

a. 一种。 Look at the 'Stats' tab on this page and see what happens. 查看此页面上的“统计信息”标签,看看会发生什么。

b. b。 After expiration the browser will check at the server if the file is updated. 到期后,浏览器将在服务器上检查文件是否已更新。 If not, the server will respond with a 304 Not Modified header and nothing is downloaded. 否则,服务器将以304 Not Modified标头响应,并且不会下载任何内容。

You can check this behaviour yourself by looking at the 'Net' panel in Firebug or similar tools. 您可以通过查看Firebug或类似工具中的“网络”面板来自己检查此行为。 Just re-enter the URL in the address bar and compare the number of HTTP requests with the number of requests when your cache is empty. 只需在地址栏中输入URL,然后将HTTP请求数与缓存为空时的请求数进行比较即可。

The given answers are incorrect, at least for web browsers in 2019. 给出的答案不正确,至少对于2019年的Web浏览器而言。

"After expiration the browser will check at the server if the file is updated" <- not true “到期后,浏览器将在服务器上检查文件是否已更新” <-不是

I have a static file served with "Cache-Control: public,must-revalidate,max-age=864000" and both Chrome and Firefox do a request every time (and get a 304 Not Modified back every time). 我有一个静态文件,其中包含“高速缓存控件:public,必须重新验证,最大使用期限= 864000”,Chrome和Firefox每次都发出请求(并每次返回304 Not Modified)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP Cache-Control 标头 max-age 与 max-age,必须重新验证 - HTTP Cache-Control header max-age vs max-age, must-revalidate max-age,no-Cache,必须在Cache-Control Header上重新验证,在此优先? - max-age, no-Cache,must-revalidate on Cache-Control Header, Which takes predence here? “no-cache”vs“max-age = 0,must-revalidate,proxy-revalidate” - “no-cache” ​vs “max-age=0, must-revalidate, proxy-revalidate” 同时使用“ Expires:0”,“ no-cache”,“ no-store”,“ max-age = 0,必须重新验证”-做什么用? - Simultaneous use of “Expires: 0”, “no-cache”, “no-store”, “max-age=0, must-revalidate” - what for? 即使使用Etag,更改静态文件的URL仍然返回304,max-age:0,必须重新验证和无缓存 - Changed static file's URL still returns 304 even with Etag, max-age: 0, must-revalidate and no-cache 在“Cache-Control:no-cache,must-revalidate”中使用“must-revalidate”是多么必要 - How necessary it is to use “must-revalidate” in “Cache-Control: no-cache, must-revalidate” http请求中的cache-control:max-age = 0和If-Not-Modified - cache-control:max-age=0 and If-Not-Modified in http request http请求中的“ cache-control:max-age = 0” - `cache-control: max-age=0` in http request no-cache 和 must-revalidate 之间的区别 - Difference between no-cache and must-revalidate 结合缓存控制的 http 304 响应似乎不适用于 max-age - http 304 response combined with cache-control does not seem to work with max-age
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM