Skip to content

Commit

Permalink
allow static public files to be cached on drupal sites
Browse files Browse the repository at this point in the history
  • Loading branch information
drasgardian committed Oct 20, 2020
1 parent 960b869 commit 9113980
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions templates/presets/drupal.vcl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ sub vcl_recv {
}
else {
# If there is any cookies left (a session or NO_CACHE cookie), do not
# cache the page. Pass it on to Apache directly.
return (pass);
# cache anything EXCEPT static files.

{{ $static_files := (getenv "VARNISH_STATIC_FILES" "asc|doc|xls|ppt|csv|svg|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm|webp") }}

if (!((getenv "VARNISH_CACHE_STATIC_FILES") && (req.url ~ "(?i)\.({{ $static_files }})(\?.*)?$"))) {
# Not a static file or VARNISH_CACHE_STATIC_FILES not set.
# Proceed directly to apache, skipping static.vcl processing.
return (pass);
}
}
}
}

0 comments on commit 9113980

Please sign in to comment.