【发布时间】:2012-03-24 00:03:43
【问题描述】:
我正在尝试通过让 Varnish 继续提供这些页面的旧缓存版本(又名宽限模式)来解决后端服务器的问题,该服务器将不时开始提供具有 200 OK 响应的空白页面。
首先我尝试检查vcl_fetch 中的响应,但据我所知,无法确定vcl_fetch 中的内容长度。然后我尝试在vcl_deliver 中完成这项工作(Content-Length 标头可用)。这确实有效,但我不知道如何删除坏缓存对象(带有空白页的对象),所以这似乎是不行的。
有人建议我在vcl_deliver 中设置 obj.grace 和 obj.ttl,这是我当前的代码:
sub vcl_deliver {
# If the front page is blank, invalidate this cached object, in hope
# that we'll get a new one.
if (req.url == "/" && std.integer(resp.http.content-length, 0) < 1000) {
set obj.grace = 0m;
set obj.ttl = 0m;
return(restart);
}
}
但是,Varnish 不喜欢这样,并在我尝试加载 VCL 时给我这个错误:
Message from VCC-compiler:
'obj.grace': cannot be set in method 'vcl_deliver'.
At: ('input' Line 146 Pos 9)
set obj.grace = 0m;
--------#########------
如果我删除 obj.grace 行,obj.ttl 会出现相同的错误 - 即使 the docs say otherwise 似乎也无法在 vcl_deliver 中写入。这是在 Varnish 3.0.2 上。
【问题讨论】:
标签: varnish varnish-vcl