Last active
December 21, 2016 17:49
-
-
Save rezan/c7bd24f269557e0f8af5e4ba218bc495 to your computer and use it in GitHub Desktop.
A generic Varnish Cache worldpress VCL template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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