Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

obj.ttl in Varnish 4.0

Question about obj.ttl in Varnish 4.0

I have a small varnish problem and hope anyone can help me. I am using varnish 4.0 and I want to increase the obj.ttl based on the obj.hits

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

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

Unfortunately, I receive an error. Message from VCC-compiler:

 Variable 'obj.ttl' is read only.
 At: ('input' Line 46 Pos 21)
like image 318
user3589380 Avatar asked Apr 30 '14 13:04

user3589380


1 Answers

In Varnish 4, the entire obj variable is read-only:

obj is now read-only

obj is now read-only. obj.hits, if enabled in VCL, now counts per objecthead, not per object. obj.last_use has been retired.

Use beresp.ttl instead (see the VCL reference). I suggest reading the entire Upgrading To Varnish 4 document.

like image 104
Brandon Wamboldt Avatar answered Oct 10 '22 17:10

Brandon Wamboldt