I'm currently installing a new server and i want to use varnish for cache system. I follow this tutorial to set up with apache.
When i restart the varnish service it give me this error :
* Stopping HTTP accelerator varnishd [fail]
* Starting HTTP accelerator varnishd [fail]
SMF.s0: filename: /var/lib/varnish//varnish_storage.bin size 1024 MB.
Message from VCC-compiler:
Expected ';' got '('
(program line 174), at
('input' Line 27 Pos 22)
purge("req.url ~ " req.url " && req.http.host == " req.http.host);
---------------------#------------------------------------------------------------
Running VCC-compiler failed, exit 1
Any idea to solve this ? (i use the last version of varnish on a Ubuntu 11.04)
** EDIT add default.vcl **
backend apache {
.host = "127.0.0.1";
.port = "8008";
}
acl purge {
"localhost";
"127.0.0.1";
}
sub vcl_recv {
// Strip cookies for static files:
if (req.url ~ "\. (jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
unset req.http.Cookie;
return(lookup);
}
// Remove has_js and Google Analytics __* cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");
// Remove a ";" prefix, if present.
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
// Remove empty cookies.
if (req.http.Cookie ~ "^\s*$") {
unset req.http.Cookie;
}
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
purge("req.url ~ " req.url " && req.http.host == " req.http.host);
error 200 "Purged.";
}
}
sub vcl_hash {
if (req.http.Cookie) {
set req.hash += req.http.Cookie;
}
}
sub vcl_fetch {
// Strip cookies for static files:
if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
unset beresp.http.set-cookie;
}
// Varnish determined the object was not cacheable
if (!beresp.cacheable) {
set beresp.http.X-Cacheable = "NO:Not Cacheable";
} elsif(req.http.Cookie ~"(UserID|_session)") {
// You don't wish to cache content for logged in users
set beresp.http.X-Cacheable = "NO:Got Session";
return(pass);
} elsif ( beresp.http.Cache-Control ~ "private") {
// You are respecting the Cache-Control=private header from the backend
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
return(pass);
} elsif ( beresp.ttl < 1s ) {
// You are extending the lifetime of the object artificially
set beresp.ttl = 300s;
set beresp.grace = 300s;
set beresp.http.X-Cacheable = "YES:Forced";
} else {
// Varnish determined the object was cacheable
set beresp.http.X-Cacheable = "YES";
}
return(deliver);
}
Your issue is in the purge line.. bad use of quotes
should be like