I am new to Varnish, and I am running v4.0 on Debian Wheezy.
I would like to set a default TTL across my cache of 4 weeks (very static content).
From reading the docs I think the answer is to set a default_ttl
option somewhere in my VCL file. I have searched the docs but can only find one reference to it.
I've found this question but I think the answer must be out of date, because it doesn't work for me.
Could someone clarify how to do this in Varnish 4.0?
UPDATE: Here's my config file (the default that ships with Varnish 4.0, except that I've pointed the backend at localhost):
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_backend_fetch {
set obj.ttl = 4w;
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
}
sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
}