0

我正在尝试使用 php header() 函数为我的页面设置缓存标头。我有一个缓存 http 请求的 CDN。我在这里想要实现的是 CDN 应该将我的页面缓存 2 天,并且浏览器应该每 5 分钟检查一次 CDN 的新版本。

Cache-Control: max-age=300, s-maxage=172800, public

这个 avoe 缓存标头有效吗?

4

2 回答 2

1

这个 avoe 缓存标头有效吗?

为什么你不知道你的流量?

手册

s-maxage
   If a response includes an s-maxage directive, then for a shared
   cache (but not for a private cache), the maximum age specified by
   this directive overrides the maximum age specified by either the
   max-age directive or the Expires header.

是的,它应该可以工作 - 但在客户端上使用比在中间代理上更短的到期时间是没有意义的(除非客户端可能在不同的 CDN 区域之间移动并且内容是特定于 CDN 区域的)。

于 2012-09-07T15:37:04.513 回答
0

expires 标头是您要查找的标头,它告诉所有缓存相关表示的新鲜时间。在那之后,缓存将始终与原始服务器核对以查看文档是否已更改。

此外,如果您的页面没有密码保护,请使用must-revalidate.

您可以在 CDN 上使用一种方法将您的 TTL 设置为 2 天

于 2012-09-07T14:19:06.647 回答