I have a varnish 3.xx server which currently works.
Varnish is caching the login page of my site.
but it may have different urls depending on the staff members link, for example
http://www.mysite.com/staff/index.php?/Tickets/Ticket/View/222200
My varnish config file is set as follows to exclude caching the staff page, but it is not working, as it is caching the login page and it is will not login untill i restart varnish to clear it’s cache.
sub vcl_recv {
# Allow purge only from internal users
if (req.request == "PURGE") {
if (!client.ip ~ internal_net) {
error 405 "Not allowed.";
}
return (lookup);
# Exclude the following
if (req.url ~ "^/login\.php" ||
req.url ~ "^/search\.php" ||
req.url ~ "^/admin(.*)" ||
req.url ~ "^/admin(.*)" ||
req.url ~ "^/search(.*)" ||
req.url ~ "^/visitor(.*)" ||
req.url ~ "^/staff(.*)" ||
req.url ~ "^/staff\.php"
) {
return(pass);
}
if (req.http.cookie ~ "vb(.*)" ||
req.http.cookie ~ "bb(.*)" ||
req.http.cookie ~ "SWIFT_(.*)" ||
req.url ~ "\?(.*\&)?s=[a-fA-F0-9]{32}(\&|$)" ||
req.http.cookie ~ "bb_password") {
return(pass);
} else {
unset req.http.cookie;
}
}
Do you perhaps have another method to exclude and entire directory from being cached?
IE: everything from /staff no matter what the suffix is after that must not be cached
The exclusion should work perfectly the way you have implemented it. However if the code you pasted is your actual VCL you have an open if() statement in the PURGE section.
should read
Varnish should not accept invalid VCL though, so if the error does not exist in your actual VCL, please update the question with your entire VCL.