Skip to content

Instantly share code, notes, and snippets.

@Mad182
Created June 27, 2013 09:55
Show Gist options
  • Save Mad182/5875325 to your computer and use it in GitHub Desktop.
Save Mad182/5875325 to your computer and use it in GitHub Desktop.
My Varnish configuration
#
# 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