Varnish Cache – Default TTL

cachettlvarnish

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) ?

Best Answer

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.

Related Topic