Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
Created December 15, 2017 04:59
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/13df1af6d7c600e02eeca3196549bda4 to your computer and use it in GitHub Desktop.
Save section-io-gists/13df1af6d7c600e02eeca3196549bda4 to your computer and use it in GitHub Desktop.
Increase browser cache TTL in Varnish VCL 4.0
# Cache statics
if ((bereq.url ~ "\.(css)(?=\?|&|$)" && beresp.http.Content-Type ~ "text/css")
|| (bereq.url ~ "\.(jpe?g|png|gif|ico)(?=\?|&|$)" && beresp.http.Content-Type ~ "image/")
|| (bereq.url ~ "\.(js)(?=\?|&|$)" && beresp.http.Content-Type ~ "javascript")
|| (bereq.url ~ "\.(swf)(?=\?|&|$)" && beresp.http.Content-Type ~ "application/x-shockwave-flash")
|| (bereq.url ~ "\.(woff)(?=\?|&|$)" && beresp.http.Content-Type ~ "font")) {
set beresp.http.Cache-Control = "public, max-age=604800"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment