I've been following this guide which uses this default.vcl. However, when starting Varnish I get the following error:
* Starting HTTP accelerator [fail]
storage_malloc: max size 1024 MB.
Message from VCC-compiler:
Expected '(' got ';'
(program line 341), at
(input Line 43 Pos 22)
purge;
---------------------#
Running VCC-compiler failed, exit 1
VCL compilation failed
Which means that there is something wrong with purge here:
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
I don't see anything wrong, can someone explain?
Thanks!
The code block you have used is perfectly valid - in fact I use a nearly identical one with my Varnish setup (and I presume many others do as well).
As the error suggests there is a problem with
purge
. Sincepurge
was only introduced in Varnish 3.x, if you are using a prior version of Varnish (2.x) the command will be unrecognised, and compilation will fail. You can determine your version of Varnish by runningvarnishd -V
.If you are using a previous version of Varnish, and are unable to upgrade, the equivalent command is
set obj.ttl = 0s;
.Varnish maintains up-to-date repositories for Ubuntu/Debian and RHEL/CentOS distributions on their download page.