Varnish maximum “set beresp.ttl” value

varnish

I'm trying to set 100 days = 144000m ttl for varnish cache for a certain page but I observed Varnish is purging cached pages.

So question what is the maximum ttl that I can set

if ((req.url ~ "\.(html)$") && (beresp.ttl > 0s)) {
   unset beresp.http.cache-control;
   unset beresp.http.expires;
   unset beresp.http.cookie;
   set beresp.do_gzip = true;
   set beresp.http.Cache-Control = "public, max-age=14411, s-maxage=14411";
   remove beresp.http.Pragma;
   set beresp.ttl = 144000m;
   return(deliver);

Best Answer

ttl is a float internally, where 0 means the UNIX epoch. It can typically store up to 3.402823e+38 or thereabouts, which translates to somewhere in the region of 10^31 years, though with some loss of precision as you get far from epoch.

If pages are evicted from the cache, I'd look at them being removed ("LRU nuked" in varnishstat) instead. You might also just want to write 100 days as "100d" rather than counting minutes.