在Varnish 4.0中的obj.ttl

时间:2014-04-30 13:03:14

标签: varnish varnish-vcl

关于Varnish 4.0中obj.ttl的问题

我有一个小清漆问题,希望有人可以帮助我。 我正在使用清漆4.0,我想基于obj.hits增加obj.ttl

sub vcl_hit {
  if (obj.hits == 1000) {
    set obj.ttl = 7d;
  }
}

sub vcl_fetch {
  set beresp.ttl = 20m;
}

不幸的是,我收到了一个错误。  来自VCC编译器的消息:

 Variable 'obj.ttl' is read only.
 At: ('input' Line 46 Pos 21)

1 个答案:

答案 0 :(得分:8)

在Varnish 4中,the entire obj variable is read-only

  

obj现在是只读的

     

obj现在是只读的。 obj.hits,如果在VCL中启用,现在计算每个对象头,而不是每个对象。 obj.last_use已经退休。

改为使用beresp.ttlsee the VCL reference)。我建议您阅读整个Upgrading To Varnish 4文档。