Skip to content

Instantly share code, notes, and snippets.

@rezan
Last active December 21, 2016 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezan/c7bd24f269557e0f8af5e4ba218bc495 to your computer and use it in GitHub Desktop.
Save rezan/c7bd24f269557e0f8af5e4ba218bc495 to your computer and use it in GitHub Desktop.
A generic Varnish Cache worldpress VCL template
# Worldpress Varnish Cache VCL template
# 12/21/2016
vcl 4.0;
backend wordpress {
.host = "0.0.0.0";
.port = "0";
}
acl purge_hosts {
"127.0.0.1";
}
sub vcl_recv {
set req.backend_hint = wordpress;
if (req.method == "PURGE") {
if (!(client.ip ~ purge_hosts)) {
return(synth(405,"Not allowed."));
}
return (purge);
}
if (req.http.cookie ~ "wordpress_logged_in") {
return(pass);
}
if ((req.url ~ "wp-(login|admin)") || (req.url ~ "preview=true")) {
return(pass);
}
unset req.http.cookie;
}
sub vcl_backend_response {
#do TTL overrides here
set beresp.grace = 1d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment