Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Looks like I've found the answer: 120 seconds - this is in the default VCL logic. –  Ade May 15 '12 at 11:42

2 Answers 2

up vote 11 down vote accepted

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.

share|improve this answer
    
Where did you find the default template? –  Neil Oct 25 '13 at 15:37
    

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 http://stackoverflow.com/questions/12691489/varnish-hit-for-pass-means

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.