Created
June 27, 2013 09:55
-
-
Save Mad182/5875325 to your computer and use it in GitHub Desktop.
My Varnish configuration
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
# | |
# My varnish config | |
# caches all static files (images, js, css, txt, flash) | |
# but requests from backend dinamic content | |
# | |
# webserver | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
} | |
# what files to cache | |
sub vcl_recv { | |
if (req.url ~ "\.(png|gif|jpg|ico|txt|swf|css|js)$") { | |
return(lookup); | |
} | |
} | |
# strip the cookie before the image is inserted into cache. | |
sub vcl_fetch { | |
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") { | |
unset beresp.http.set-cookie; | |
} | |
} | |
# add response header to see if document was cached | |
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