Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
Last active January 27, 2016 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save section-io-gists/0147f11db037f6bd307a to your computer and use it in GitHub Desktop.
Save section-io-gists/0147f11db037f6bd307a to your computer and use it in GitHub Desktop.
section.io VCL - Performance Config
#section.io VCL sample. Copy paste into your section.io account to implement instantly
#vcl_recv - copy this code into the section called sub vcl_recv
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} else if (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
if (req.url ~ ".*\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") {
unset req.http.Cookie;
#Varnish <= 3.x calls this "return (lookup);" instead of "return (hash);"
return (hash);
}
#vcl_backend_response - copy this code into the section called sub vcl_backend_response
#Varnish <= 3.x calls this "vcl_fetch" instead of "vcl_backend_response"
if (beresp.status < 400){
if (bereq.url ~ ".*\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") {
set beresp.ttl = 28800s; #The number of seconds to cache inside Varnish
set beresp.http.Cache-Control = "max-age=28800"; #The number of seconds to cache in browser
}
}
#vcl_deliver - copy this code into the section called sub vcl_deliver
if (resp.http.x-varnish ~ " ") {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
@section-io-gists
Copy link
Author

Adjust config to be V4 centric with V3.X comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment