Created
May 5, 2013 14:40
-
-
Save barek2k2/5520990 to your computer and use it in GitHub Desktop.
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
/etc/varnish/default.vcl | |
backend default { | |
.host = "127.0.0.1"; | |
.port = "8080"; | |
} | |
acl purge { | |
"localhost"; | |
} | |
sub vcl_recv { | |
if (req.request == "PURGE") { | |
if(!client.ip ~ purge) { | |
error 405 "Not allowed."; | |
} | |
purge("req.url ~ ^" req.url "$ && req.http.host == "req.http.host); | |
} | |
} | |
sub vcl_recv { | |
#Clears all caches if requesting method is post or put or delete | |
if (req.request == "POST" || req.request == "PUT" || req.request == "DELETE") { | |
purge("req.url == " req.url " && req.http.host == " req.http.host); | |
} | |
} | |
sub vcl_fetch { | |
# Make cache for all get request | |
if (req.request == "GET") { | |
unset beresp.http.Set-Cookie; | |
set beresp.cacheable = true; | |
set beresp.ttl = 60m; | |
} | |
if (req.url ~ "^/images/" || req.url ~ "^/javascripts" || req.url ~ "^/stylesheets"){ | |
set beresp.ttl = 60m; | |
} | |
} | |
/etc/default/varnish | |
DAEMON_OPTS="-a :80 \ | |
-T localhost:6082 \ | |
-f /etc/varnish/default.vcl \ | |
-S /etc/varnish/secret \ | |
-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment