按CTRL + F5或CTRL + R时清除光油中的内容

我想设置Varnish来清除caching中的内容,并在按CTRL + R或CTLR + F5时直接从后端获取。

我使用这些规则,但只有按CTRL + F5时才从后端获取内容。 当我按F5只有我从caching中获取数据。

acl CTRLF5 { "127.0.0.1"; } sub vcl_hit { if (client.ip ~ CTRLF5) { if (req.http.pragma ~ "no-cache" || req.http.Cache-Control ~ "no-cache") { set obj.ttl = 0s; return(pass); } else { return(deliver); } } else { return(deliver); } } 

可以用下面的语句来实现:

清漆2.1.x

  if (req.http.Cache-Control ~ "no-cache"){ purge_url(req.url); } 

清漆3.x

  if (req.http.Cache-Control ~ "no-cache"){ ban(req.url); }