1

我是 Varnish 的新手,我很难理解为什么这么多请求是 amisshit_for_pass.

我已经添加unset req.http.Cookie;vcl_recv(如果我是对的)有效地忽略所有 cookie 并缓存而不考虑 cookie?这是正确的吗?

但尽管如此,我仍然没有hits。所以这种 cookie 方法要么是错误的,要么是完全不同的原因导致它不起作用。

关于这个的任何想法,或者有没有办法确切地了解我为什么经常得到hit_for_passmiss如此频繁。

谢谢杰克

编辑

更多谷歌搜索,我发现了这个

sub vcl_fetch {
    unset beresp.http.set-cookie; 
}

所以我想这会从响应对象中删除 cookie,有人可以解释为什么现在可以工作以及我做了什么来让它工作吗?

编辑2

再看一遍,varnishstat这并没有像我预期的那样工作,而且我仍然有很多失误。

4

2 回答 2

2

很有可能,如果你有很多hit_for_pass决定,缓存本身也很少,因此会失败。

hit_for_pass我相信,它只是从方法中抛出的vcl_fetch,所以值得看看你的服务器返回了什么。需要考虑的事项包括:

  • remove beresp.http.Cache-Control;remove beresp.http.Pragma; 阻止您的后端应用程序阻止缓存。

  • remove beresp.http.Expires;以避免现在/过去的到期日期(您可能希望将其更改为远期到期,具体取决于您所服务的内容)。

  • 如果您的应用不提供 cookie,那么remove beresp.http.Set-Cookie;将对您的 hit_for_pass 率产生很大影响。

  • 确保您设置了适当的beresp.ttl值。

I'd also recommend that you read this article about the 'Accept-Encoding' header (the code in the example goes in the vcl_recv method).

于 2012-07-31T13:04:15.257 回答
1

For others who may have this issue, this was useful.

https://www.varnish-cache.org/trac/wiki/VCLExampleHitMissHeader

Setting headers to show what is and is not cached and why.

于 2012-08-01T08:54:24.463 回答