我试图让 Varnish 与上次修改的 header 一起工作,但无论我做什么,我的页面都会在 120 秒内缓存,并且 Varnish 永远不会与后端重新验证。
我的后端正在发送这些 header :
Cache-Control: must-revalidate, proxy-revalidate, public, stale-while-revalidate=0
Last-Modified: Fri, 22 Jan 2016 03:32:33 GMT
当我记录命中时对象的 TTL 时,它的值始终设置为 120 秒。
我正在使用 Varnish 4 的默认 VCL 配置。
问候,
编辑:经过一番搜索,我发现120s是Varnish的默认ttl值。但为什么他忽略了最后修改呢?
最佳答案
设置 Cache-Control header 的“s-maxage”或“max-age”属性:
beresp.ttl is initialized with the first value it finds among:
The s-maxage variable in the Cache-Control response header field The max-age variable in the Cache-Control response header field The Expires response header field The default_ttl parameter.
关于Varnish 4 不支持缓存控制 : must-revalidate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34938706/