Quick explanation of the VCL commands?

Anton Stonor stonorn at giraffen.dk
Thu Nov 9 21:06:20 CET 2006


Hi Lennart,


> However, I'm gonna spend tomorrow trying to optimize the configuration
> and would like to understand VCL a bit better. Mostly, I wonder if
> there is a document that explains, or if somebody can quickly explain,
> what all the VCL commands, pipe, pass, insert_pass and so on do.

I don't thing a full documentation is there yet, but this man-page might 
be useful:

http://varnish.projects.linpro.no/browser/trunk/varnish-cache/man/vcl.7

Also, have a look at PHK's presentation -- the diagram on page 20 is 
helpful in understanding of what is going on:

http://phk.freebsd.dk/pubs/varnish_wip.pdf

Finally, the default VCL snippet is worth a look (from my notepad, might 
have changed since):

--- snippet ---

sub default_vcl_recv {
     if (req.request != "GET" && req.request != "HEAD") {
         pipe;
         }
     if (req.http.Expect) {
             pipe;
     }
     if (req.http.Authenticate || req.http.Cookie) {
         pass;
     }
     lookup;
}

sub default_vcl_hit {
     if (!obj.cacheable) {
         pass;
     }
     deliver;
}

default_vcl_miss {
     fetch;
}

sub default_vcl_fetch {
     if (!obj.valid) {
         error;
     }
     if (!obj.cacheable) {
         insert_pass;
     }
     if (resp.http.Set-Cookie) {
         insert_pass;
     }
     insert;
}

sub default_vcl_timeout {
     discard;
}

--- snippet end ---

/Anton



More information about the varnish-misc mailing list