【问题标题】:What does varnish hit-for-passvarnish hit-for-pass 是什么意思
【发布时间】:2017-08-11 10:08:56
【问题描述】:

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

在使用清漆配置后,我们发现了那条线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);
}

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

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

在我的情况下,我的后端中的错误会生成 500 无缓存,然后导致更多流量,最后导致 503...

我打算删除这条规则,但我想在此之前了解它。

有什么线索吗?

提前致谢 M.

【问题讨论】:

    标签: caching varnish varnish-vcl


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2020-05-14
      • 2016-04-24
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      相关资源
      最近更新 更多