Skip to content

Instantly share code, notes, and snippets.

@maxcountryman
Created November 11, 2010 01:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxcountryman/671807 to your computer and use it in GitHub Desktop.
Save maxcountryman/671807 to your computer and use it in GitHub Desktop.
Voxi VCL
backend primary {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"127.0.0.1";
}
sub vcl_recv {
set req.backend = primary;
# Filter PURGE requests
if (req.request == "PURGE") {
if(!client.ip ~ purge) {
error 405 "Not allowed.";
}
# Purge URLs matching a regex
purge("req.url ~ " req.url " && req.http.host == " req.http.host);
error 200 "Purged";
}
# Don't cache POSTSs
if(req.request == "POST") {
return(pass);
}
# Only cache these domain(s)
if (!(req.http.host ~ "^(www.)?voxinfinitus\.net"))
{
return(pass);
}
# Allow uncached access to the admin
if (req.url ~ "^/admin") {
return(pass);
}
# Normalize Accept-Encoding to reduce vary
if (req.http.Accept-Encoding) {
if (req.http.User-Agent ~ "MSIE 6") {
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
# Strip cookies
unset req.http.cookie;
# Don't respect pragma: no-cache or Cache-Control: no-cache
unset req.http.Pragma;
unset req.http.Cache-Control;
# Enable a one-minute grace period: http://www.varnish-cache.org/wiki/VCL#Grace
set req.grace = 1m;
}
sub vcl_fetch {
# Don't cache POSTSs
if(req.request == "POST") {
return(pass);
}
# Only cache these domain(s)
if (!(req.http.host ~ "^(www.)?.voxinfinitus\.net"))
{
return(pass);
}
# Allow uncached access to the admin
if (req.url ~ "^/admin") {
return(pass);
}
# Don't cache things which specifically say not to
if (beresp.http.Cache-Control ~ "no-cache") {
return(pass);
}
# Process Edge-side includes
esi;
# Strip cookies
unset beresp.http.Set-Cookie;
# Enable a one-minute grace period: http://www.varnish-cache.org/wiki/VCL#Grace
set req.grace = 1m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment