Mailing List Archive

VCL documentation
Hi.

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.

--
Trond Michelsen
VCL documentation [ In reply to ]
In message <20060920132240.GG13253 at crusaders.no>, Trond Michelsen writes:
>Hi.
>
>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 backend.host = "10.0.2.1";
set backend.port = "80";
}

acl purge {
"localhost";
"10.0.0.1";
}

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

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.
VCL documentation [ In reply to ]
Trond Michelsen <trondmm-varnish at crusaders.no> 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.

I am working on a vcl(7) manual page, which will hopefully be included
along with a few bug fixes in a 1.0.1 release tomorrow or Friday.

Here's a wiki page with a config I've used to test how well a stock
Varnish install handles the major Norwegian online news outlets:

http://varnish.projects.linpro.no/wiki/NorskeNettaviser

(Varnish is very flexible, but we want it to run well "out of the box"
so it will be useful in an emergency when you don't have time to read
the docs and write a config file)

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
VCL documentation [ In reply to ]
On Wed, Sep 20, 2006 at 02:43:15PM +0000, Poul-Henning Kamp wrote:
> In message <20060920132240.GG13253 at crusaders.no>, 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.

Thanks.

So, if I want to cache absolutely everything that is requested through
the cache, no matter what the headers might say, I could write
something like this:

sub vcl_fetch {
insert;
}

Would that work?

> 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.

Ah, OK.

--
// Trond Michelsen
\X/ mike at crusaders.no
VCL documentation [ In reply to ]
In message <20060920194410.GB19935 at crusaders.no>, Trond Michelsen writes:
>On Wed, Sep 20, 2006 at 02:43:15PM +0000, Poul-Henning Kamp wrote:
>> In message <20060920132240.GG13253 at crusaders.no>, 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.
>
>Thanks.
>
>So, if I want to cache absolutely everything that is requested through
>the cache, no matter what the headers might say, I could write
>something like this:
>
>sub vcl_fetch {
> insert;
>}
>
>Would that work?

You should probably also do:

sub vcl_recv {
lookup;
}


--
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.