Created
November 21, 2012 21:45
-
-
Save HoundstoothSTL/4128041 to your computer and use it in GitHub Desktop.
Varnish vcl file
This file contains 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
## Varnish to sit on top of Nginx web server | |
## App running on WordPress with W3 Total Cache plugin running | |
backend default { | |
.host = "localhost"; | |
.port = "8080"; | |
} | |
acl purge { | |
"localhost"; | |
} | |
sub vcl_recv { | |
if (req.request == "PURGE") { | |
if (!client.ip ~ purge) { | |
error 405 "Not allowed."; | |
} | |
return(lookup); | |
} | |
if (req.url ~ "^/$") { | |
unset req.http.cookie; | |
} | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
set obj.ttl = 0s; | |
error 200 "Purged."; | |
} | |
} | |
sub vcl_miss { | |
if (req.request == "PURGE") { | |
error 404 "Not in cache."; | |
} | |
if (!(req.url ~ "wp-(login|admin)")) { | |
unset req.http.cookie; | |
} | |
if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz| | |
zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") { | |
unset req.http.cookie; | |
set req.url = regsub(req.url, "\?.$", ""); | |
} | |
if (req.url ~ "^/$") { | |
unset req.http.cookie; | |
} | |
} | |
sub vcl_fetch { | |
if (req.url ~ "^/$") { | |
unset beresp.http.set-cookie; | |
} | |
if (!(req.url ~ "wp-(login|admin)")) { | |
unset beresp.http.set-cookie; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment