1 #-e This is a basic VCL configuration file for varnish. See the vcl(7)
2 #man page for details on VCL syntax and semantics.
12 if (req.http.Cache-Control ~ "(?i)no-cache") {
13 # Ignore requests via proxy caches and badly behaved crawlers
14 if (! (req.http.Via || req.http.User-Agent ~ "(?i)bot" || req.http.X-Purge)) {
15 return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops
21 # Only handle actual PURGE HTTP methods, everything else is discarded
22 if (req.method != "PURGE") {
24 set req.http.X-Purge = "Yes";
29 # We rate-limit requests by clients.
30 # Currently, we do that at the netfilter level, so one
31 # request per connection works best.
33 if (remote.ip != "127.0.0.1" &&
35 set resp.http.connection = "close";
39 sub vcl_backend_response {
40 if (bereq.retries == 0 &&
41 beresp.status == 302 &&
42 beresp.http.location ~ "https?://[^/]*/file/") {
43 set beresp.http.location = regsub(beresp.http.location,"^https?://","");
44 set bereq.http.host = regsub(beresp.http.location,"/.*$","");
45 set bereq.url = regsub(beresp.http.location,"[^/]*","");