I have discovered that I can set the TTL in Varnish as follows in my VCL file:
sub vcl_fetch {
# 1 minute
set obj.ttl = 1m;
}
But what is the default setting (assuming the backend server is setting no cache-control header) ?
I have discovered that I can set the TTL in Varnish as follows in my VCL file:
sub vcl_fetch {
# 1 minute
set obj.ttl = 1m;
}
But what is the default setting (assuming the backend server is setting no cache-control header) ?
Default TTL can be passed through the varnishd command via the -t
commandline switch and is probably sourced from a properties file on your filesystem. On the CentOS system I'm looking at it is set using DEFAULT_TTL
from /etc/sysconfig/varnish
.
You can see the live setting using varnishadm like so,
varnishadm param.show default_ttl
Actually, following default VCL logic relates to non-cacheable objects.
sub vcl_fetch {
if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
/*
* Mark as "Hit-For-Pass" for the next 2 minutes
*/
set beresp.ttl = 120 s;
return (hit_for_pass);
}
return (deliver);
}
means "if object is not cacheable - pass client requests for this object to backend directly and simultaneously for 2 minutes, do not queue them"
Read more at https://stackoverflow.com/questions/12691489/varnish-hit-for-pass-means
This is in the default template:
sub vcl_fetch {
if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
/*
* Mark as "Hit-For-Pass" for the next 2 minutes
*/
set beresp.ttl = 120 s;
return (hit_for_pass);
}
return (deliver);
}
So, 120 seconds.