是否可以为Varnish中的不同路径设置不同的宽限期?

时间:2018-12-26 15:29:24

标签: varnish

我在Haproxy之后使用Varnish,并且缓存时间(ttl)由后端使用适当的标头确定。在Varnish方面,我想为各个路径设置不同的宽限期,因为对于某些路径,1h宽限期是可以的,但对于另一些路径,超过1分钟是不可接受的。

我已经尝试过类似下面的方法,但是它似乎不起作用:

sub vcl_backend_response {
    unset beresp.http.Set-Cookie;

    if (bereq.url ~ "^/products/\d+/details") {
       # cached for 1h, want to add +1h grace
       set beresp.grace = 1h;
    }
    if (bereq.url ~ "^/products/timeline") {
       # cached for 30s, want to add +1m grace
       set beresp.grace = 1m;
    }
}

是否可以为不同的路径设置不同的宽限时间,或通过其他任何方式来提供过时的内容,直到更新缓存为止?

0 个答案:

没有答案
相关问题