我正在尝试使用php-header()函数为我的页面设置缓存头。我有一个缓存http请求的CDN。我在这里试图实现的是,CDN应该缓存我的页面2天,浏览器应该每5分钟检查一次CDN的新版本。
Cache-Control: max-age=300, s-maxage=172800, public
这个avoe缓存头工作吗?
这个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区域的)。
expires头是您要查找的头,它告诉所有缓存关联表示的新鲜时间。在此之后,缓存将始终与原始服务器进行核对,以查看文档是否已更改。
此外,如果您的页面没有密码保护,请使用must-revalidate
。
您可以在CDN中使用一种方法将TTL设置为2天