什么是 varnish hit-for-pass

What does varnish hit-for-pass

当我们对位于 varnish 4.1 服务器后面的应用程序进行 运行 负载测试时,我们注意到在服务器错误(500 返回 Cache-Control: no-cache)之后,我们遇到了负载峰值我们的后端k.

深入研究 varnish 配置后,我们发现了那条线 https://github.com/varnishcache/varnish-cache/blob/master/bin/varnishd/builtin.vcl#L157 :

sub vcl_backend_response {
    if (bereq.uncacheable) {
        return (deliver);
    } else if (beresp.ttl <= 0s ||
      beresp.http.Set-Cookie ||
      beresp.http.Surrogate-control ~ "no-store" ||
      (!beresp.http.Surrogate-Control &&
        beresp.http.Cache-Control ~ "no-cache|no-store|private") ||
      beresp.http.Vary == "*") {
        # Mark as "Hit-For-Miss" for the next 2 minutes
        set beresp.ttl = 120s;
        set beresp.uncacheable = true;
    }
    return (deliver);
}

如果页面 returns no-cache,在接下来的 2 分钟内将无法缓存,即使下一次调用后端 returns 一个有效的可缓存的响应.

我不明白为什么这是默认行为(根据存储库历史很久以前...)

就我而言,我的后端中的一个错误生成了 500 无缓存,然后导致更多流量,最后导致 503...

我打算删除这条规则,但我想先了解一下。

有线索吗?

提前致谢 M.

您可能想阅读

https://info.varnish-software.com/blog/hit-for-pass-varnish-cache

了解击球传球。