Created
March 15, 2013 03:54
-
-
Save brilligence/5167373 to your computer and use it in GitHub Desktop.
Varnish VCL Configuration
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
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
.connect_timeout = 60s; | |
.first_byte_timeout = 60s; | |
.between_bytes_timeout = 60s; | |
.max_connections = 800; | |
} | |
acl purge { | |
"127.0.0.1"; | |
"localhost"; | |
} | |
sub vcl_recv { | |
set req.grace = 2m; | |
remove req.http.X-Forwarded-For; | |
set req.http.X-Forwarded-For = client.ip; | |
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_[_a-z]+|has_js|is_unique)=[^;]*", ""); | |
set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", ""); | |
if (req.url ~ "/wp-(login|admin|cron)") { | |
# Don't cache, pass to backend | |
return (pass); | |
} | |
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-1=[^;]+(; )?", ""); | |
set req.http.Cookie = regsuball(req.http.Cookie, "wp-settings-time-1=[^;]+(; )?", ""); | |
set req.http.Cookie = regsuball(req.http.Cookie, "wordpress_test_cookie=[^;]+(; )?", ""); | |
if (req.url ~ "wp-content/themes/" && req.url ~ "\.(css|js|png|gif|jp(e)?g)") { | |
unset req.http.cookie; | |
} | |
if (req.url ~ "/wp-content/uploads/") { | |
return (pass); | |
} | |
if (req.url ~ "^/contact/" || req.url ~ "^/links/domains-for-sale/") | |
{ | |
return(pass); | |
} | |
if (req.http.Cookie ~ "wordpress_" || req.http.Cookie ~ "comment_") { | |
return (pass); | |
} | |
if (req.request == "PURGE") { | |
if (!client.ip ~ purge) { | |
error 405 "Not allowed."; | |
} | |
return (lookup); | |
} | |
if (req.http.Cache-Control ~ "no-cache") { | |
return (pass); | |
} | |
return (lookup); | |
} | |
sub vcl_fetch { | |
set beresp.grace = 2m; | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
purge; | |
error 200 "Purged."; | |
} | |
} | |
sub vcl_miss { | |
if (req.request == "PURGE") { | |
purge; | |
error 200 "Purged."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment