【问题标题】:Boost grace period on varnish when error 500 ocurred发生错误 500 时提高清漆的宽限期
【发布时间】:2015-08-26 23:36:33
【问题描述】:

当我从后端收到错误 500 时,我使用以下代码来延长 varnish 的宽限期:

# If backend returns 500 error then boost the cache grace period...
if (beresp.status == 500) {
   set beresp.grace = 1m;
return (retry);
}

但我只想在我有另一个缓存时延长宽限期,如果我没有缓存,我只想缓存错误。

缓存的后端响应配置“vcl_backend_response”:

# Cache 1 day
if(bereq.url ~ "^/"){
    set beresp.http.X-cachePath = beresp.http.X-cachePath +  "1d::";
    unset beresp.http.set-cookie;
    unset beresp.http.Cache-Control;
    set beresp.ttl = 1d;
    set beresp.grace = 1h;
    return (deliver);
}

这可以用 varnish 4 做到吗?

谢谢大家!

【问题讨论】:

    标签: caching varnish varnish-vcl


    【解决方案1】:

    我认为您正在寻找的是Saint ModeHere 就是一个例子。

    Saint Mode 的作用与 Grace Mode 类似,但在不同的情况下,Grace Mode 在后端生病或响应时间过长时起作用,而 Saint Mode 在 不喜欢后端响应。

    在这种情况下,500 错误是您不喜欢的响应。

    遗憾的是,Saint Mode 在版本 4 中已从 Varnish 核心中移除。尽管不像 Varnish 3 中那样简单,here 是 Varnish 4 中 Saint Mode 的 VMOD

    【讨论】:

      猜你喜欢
      • 2012-09-11
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 2014-08-21
      • 2018-06-14
      • 2023-03-23
      • 2011-12-22
      相关资源
      最近更新 更多