清除caching标题到浏览器

是否可能向浏览器发送“Cache-Control:no-cache,no-store,must-revalidate”caching控制响应,而varnishcaching响应。

情景是这样的。

  • 后端发送caching控制:Cache-Control:no-cache,no-store,must-revalidate
  • 清漆应该caching响应。
  • 浏览器不应该caching内容,所以在清漆回应的浏览器应显示“caching控制:caching控制:无caching,无存储,必须重新validation”

我已经尝试使用Cache-Control:no-cache,no-store,必须在set beresp.http.Cache-Control中重新validation,但是这会导致varnish不caching响应。

下面给出了使用的vcl_backend_response。

sub vcl_backend_response { if (bereq.url == "/") { unset beresp.http.expires; unset beresp.http.set-cookie; set beresp.ttl = 3600s; set beresp.http.Cache-Control = "max-age=0"; if (beresp.status >= 400 && beresp.status <= 599) { set beresp.ttl = 0s; } } } 

任何帮助,高度赞赏。

当然,在.vclconfiguration文件中使用vcl_deliver:

 sub vcl_deliver { set resp.http.Cache-Control = "no-cache, no-store, must-revalidate, private"; set resp.http.Pragma = "no-cache"; }