Varnish 4 不支持缓存控制 : must-revalidate

标签 varnish varnish-vcl

我试图让 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.

参见:http://book.varnish-software.com/4.0/chapters/VCL_Built_in_Subroutines.html#the-initial-value-of-beresp-ttl

关于Varnish 4 不支持缓存控制 : must-revalidate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34938706/

相关文章:

Varnish 客户端 IP 未记录在 Apache 日志中

apache - Varnish绕过大文件

caching - 什么时候应该在vcl_recv和vcl_fetch下添加相同的策略?

proxy - 如何在 vcl_recv 中检查后端是否健康

caching - 如何使 Varnish 不缓存某个文件夹

reverse-proxy - Varnish 3.0 是如何处理 gzip 的?

根据状态代码清空缓存项目

list - 在 VCL(Varnish 配置语言)中定义列表

caching - 如何通过IP用Varnish 4.x缓存ESI片段和相应的输出

apache - 当网站在 Tomcat 前使用 Apache Varnish 配置时获取用户机器的 IP 地址