Created
July 5, 2013 08:02
-
-
Save unusorin/5932824 to your computer and use it in GitHub Desktop.
Varnish vcl file for Symfony2
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 = "domain.com"; | |
.port = "8000"; | |
} | |
sub vcl_recv { | |
if (req.request == "PURGE") { | |
if (!client.ip ~ purge) { | |
error 405 "Not allowed."; | |
} | |
return(lookup); | |
} | |
set req.http.Surrogate-Capability = "abc=ESI/1.0"; | |
set req.http.X-Forwarded-For = client.ip; | |
unset req.http.Cookie; | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
set obj.ttl = 0s; | |
error 200 "Purged"; | |
} | |
} | |
sub vcl_hit { | |
if (req.request == "PURGE") { | |
set obj.ttl = 0s; | |
error 200 "Purged"; | |
} | |
} | |
sub vcl_deliver{ | |
if (obj.hits > 0) { | |
set resp.http.X-Varnish-Cache = "HIT"; | |
} | |
else { | |
set resp.http.X-Varnish-Cache = "MISS"; | |
} | |
return (deliver); | |
} | |
sub vcl_fetch { | |
if (beresp.http.Surrogate-Control ~ "ESI/1.0") { | |
unset beresp.http.Surrogate-Control; | |
set beresp.do_esi = true; | |
} | |
} | |
acl purge { | |
"localhost"; | |
"127.0.0.1"/24; | |
"192.168.57.54"/24; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment