Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
section-io-gists / starterConfig.vcl
Last active January 27, 2016 03:35
section.io VCL - Starter 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.url ~ ".*\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\?|&|$)") {
unset req.http.Cookie;
#Varnish <= 3.x calls this "return (lookup);"
return (hash);
}
#vcl_backend_response - copy this code into the section called sub vcl_backend_response
@section-io-gists
section-io-gists / normaliseAcceptEncoding.vcl
Created July 2, 2015 00:34
section.io VCL - Normalise Accept Encoding
#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;
@section-io-gists
section-io-gists / cacheStaticContent.vcl
Last active December 15, 2017 05:03
section.io VCL - Static Caching
#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.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
@section-io-gists
section-io-gists / Varnish 4.0: Add HTTP response headers to indicate cache hit or miss
Last active March 5, 2022 14:29
Varnish 4.0: Add HTTP response headers to indicate cache hit/miss
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
}