HTTP 缓存控制 max-age, must-revalidate [英] HTTP Cache Control max-age, must-revalidate

查看:43
本文介绍了HTTP 缓存控制 max-age, must-revalidate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个与 Cache-Control 相关的查询.

I have a couple of queries related to Cache-Control.

如果我为静态 html/js/images/css 文件指定 Cache-Control max-age=3600, must-revalidate,并在 HTTP 标头中定义 Last Modified Header:

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:

  1. 浏览器/代理缓存(如 Squid/Akamai)是否一直到源服务器以验证在 max-age 到期之前?或者它会从缓存中提供内容直到 max-age 到期?
  2. 在 max-age 到期后(即从缓存中到期),是否有 If-Modified-Since 检查或是否从源服务器重新下载内容而不进行 If-Modified-Since 检查?
  1. Does browser/proxy cache(like Squid/Akamai) go all the way to origin server to validate before max-age expires? Or will it serve content from cache till max-age expires?
  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?

推荐答案

a) 如果服务器包含这个头:

a) If the server includes this header:

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

它告诉客户端缓存和代理缓存,一旦内容过时(超过 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. This should be the default behavior of caching systems, but the must-revalidate directive makes this requirement unambiguous.

b) 客户端应重新验证.它可能使用带有 ETag 的 If-MatchIf-None-Match 标头重新验证,或者它可能使用 If-Modified-Since或带有日期的 If-Unmodified-Since 标头.

b) The client should revalidate. 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.

这篇关于HTTP 缓存控制 max-age, must-revalidate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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