VCL documentation

Poul-Henning Kamp phk at
Wed Sep 20 16:43:15 CEST 2006

In message <20060920132240.GG13253 at>, Trond Michelsen writes:
>I've just downloaded and installed varnish, and I was just wondering
>if the VCL config language is documented somewhere, or if there are
>any examples that I could use for inspiration.

The main example right now is the default VCL code which you will
find in the source file bin/varnishd/mgt_vcc.c.

Also, this is the code we run at VG right now:

backend default {
        set = "";
        set backend.port = "80";

acl purge {

sub vcl_recv {
        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
        if (req.request == "GET" && req.http.cookie) {

sub vcl_hit {
        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged.";

sub vcl_miss {
        if (req.request == "PURGE") {
                error 404 "Not in cache.";

The important thing to know which is not obvious, is that if
you do not hit an "action" in for instance vcl_miss(), the
default vcl_miss() function will be executed and will determine
the action.

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

More information about the varnish-misc mailing list