Created
April 11, 2016 15:33
-
-
Save rifki/4a61a147f09f442f63bdeccbf9759f51 to your computer and use it in GitHub Desktop.
varnish
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 = "local.app.com"; | |
.port = "8080"; | |
} | |
sub vcl_recv { | |
if (req.request == "GET" && req.url ~ "\.(gif|jpg|jpeg|png|ico)$") { | |
return(lookup); | |
} | |
else { | |
return(pass); | |
} | |
# If our backend is down, unset all cookies and serve pages from cache. | |
if (!req.backend.healthy) { | |
unset req.http.Cookie; | |
} | |
# exclude | |
if (req.url ~ "^/admin/.*$" || | |
req.url ~ "^/user/.*$") { | |
return (pass); | |
} | |
unset req.http.Accept-Encoding; | |
unset req.http.Vary; | |
set req.http.Surrogate-Capability = "abc=ESI/1.0"; | |
} | |
sub vcl_fetch { | |
set beresp.do_esi = true; | |
set beresp.ttl = 24 h; | |
} | |
sub vcl_deliver { | |
set resp.http.X-Served-By = server.hostname; | |
if (obj.hits > 0) { | |
set resp.http.X-Cache = "HIT"; | |
set resp.http.X-Cache-Hits = obj.hits; | |
} else { | |
set resp.http.X-Cache = "MISS"; | |
} | |
return(deliver); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment