/varnish/4/default.vcl |
@@ -69,6 +69,11 @@ |
|
set req.backend_hint = vdir.backend(); # send all traffic to the vdir director |
|
### Brotli encoding support. |
if(req.http.Accept-Encoding ~ "br" && req.url !~ "\.(jpg|png|gif|gz|mp3|mov|avi|mpg|mp4|swf|wmf)$") { |
set req.http.X-brotli = "true"; |
} |
|
# When CloudFlare is in front of varnish, send the real IP address through X-Forwarded-For |
# otherwise if CloudFlare is not involved, set the X-Forwarded-For to the client IP address. |
unset req.http.X-Forwarded-For; |
@@ -262,6 +267,11 @@ |
if (req.http.Cookie) { |
hash_data(req.http.Cookie); |
} |
|
### Brotli encoding support. |
if(req.http.X-brotli == "true") { |
hash_data("brotli"); |
} |
} |
|
sub vcl_hit { |
@@ -324,6 +334,12 @@ |
set beresp.do_esi = true; |
set beresp.ttl = 24h; # Set 24h ESI |
} |
|
### Brotli encoding support. |
if(bereq.http.X-brotli == "true") { |
set bereq.http.Accept-Encoding = "br"; |
unset bereq.http.X-brotli; |
} |
|
### Set content expiration. |
## You may want to disable any expiration on the backend (ie: for Apache, disable mod_expires). |
@@ -412,10 +428,10 @@ |
# So take hits with a grain of salt |
set resp.http.X-Cache-Hits = obj.hits; |
|
# Remove some headers: PHP version |
### |
## Remove some headers: PHP version |
unset resp.http.X-Powered-By; |
|
# Remove some headers: Apache version & OS |
## Remove some headers: Apache version & OS |
unset resp.http.Server; |
unset resp.http.X-Drupal-Cache; |
unset resp.http.X-Varnish; |
@@ -422,6 +438,7 @@ |
unset resp.http.Via; |
unset resp.http.Link; |
unset resp.http.X-Generator; |
unset resp.http.X-Powered-By; |
|
return (deliver); |
} |