[英]Is s-maxage supported by browsers?
I have a hard time finding out if s-maxage
is supported by browsers, or by which versions of them.我很难确定浏览器是否支持s-maxage
,或者它们的哪个版本。
s-maxage
is primarily meant for shared caches, eg proxies or CDNs, but it seems to me that it also works in Chrome. s-maxage
主要用于共享缓存,例如代理或 CDN,但在我看来它也适用于 Chrome。 For example, with a Next.js app that uses the recommended cache-control header like this:例如,对于使用推荐的缓存控制 header的 Next.js 应用程序,如下所示:
cache-control: public, s-maxage=10, stale-while-revalidate=59
I'm seeing this behavior in Chrome:我在 Chrome 中看到了这种行为:
However, I can't find a definitive resource like a MDN document or anything that would document it.但是,我找不到像 MDN 文档或任何可以记录它的权威资源。 Anyone knows?有谁知道?
You should not expect browsers to respect s-maxage
.你不应该期望浏览器尊重s-maxage
。
As defined in the specification , s-maxage
only applies to shared caches.如规范中所 定义, s-maxage
仅适用于共享缓存。 A browser cache is generally considered to be a private cache.浏览器缓存通常被认为是私有缓存。
I think what you're seeing is just the default caching that browsers do if you're not explicit about expiration.我认为你所看到的只是浏览器在你没有明确说明过期时所做的默认缓存。 Since none of your headers provide an explicit freshness lifetime , the cache is free to assign its own heuristic freshness .由于您的标头均未提供明确的新鲜度生存期,因此缓存可以自由分配其自己的启发式新鲜度。 It's normal to see a cache hit even if you don't provide any expiration directives.即使您不提供任何过期指令,看到缓存命中也是正常的。
It is possible that the browser takes s-maxage
into account when computing its heuristic freshness, but I certainly wouldn't rely on it.浏览器在计算其启发式新鲜度时可能会考虑s-maxage
,但我当然不会依赖它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.