Last active
March 11, 2016 20:37
-
-
Save juliocc/61e7277ce07e7ca05dc2 to your computer and use it in GitHub Desktop.
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
import std; | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
.first_byte_timeout = 60s; | |
.connect_timeout = 60s; | |
.between_bytes_timeout = 60s; | |
.max_connections = 200; | |
} | |
sub vcl_recv { | |
unset req.http.X-Forwarded-For; | |
set req.http.X-Forwarded-For = client.ip; | |
if (req.http.Cookie && req.http.Cookie ~ "wordpress_") { | |
return (pass); | |
} | |
# Post requests will not be cached | |
if (req.http.Authorization || req.request == "POST") { | |
return (pass); | |
} | |
# Don't cache urls with nocache | |
if (req.url ~ "nocache") { | |
return (pass); | |
} | |
# Don't cache previews | |
if (req.url ~ "preview=true") { | |
return (pass); | |
} | |
if (req.url ~ "^/wp-(login|admin)") { | |
return (pass); | |
} | |
#Serve stale cache objects for up to 2 minutes if the backend is down | |
set req.grace = 120s; | |
unset req.http.cookie; | |
} | |
sub vcl_fetch { | |
if (!(req.url ~ "^/wp-(login|admin)")) { | |
unset beresp.http.set-cookie; | |
} | |
} | |
sub vcl_deliver { | |
if (obj.hits > 0) { | |
set resp.http.X-Cache = "HIT"; | |
} else { | |
set resp.http.X-Cache = "MISS"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment