Skip to content

Commit

Permalink
Merge pull request #988 from PHOENIX-MEDIA/fix-vary-on-static-files
Browse files Browse the repository at this point in the history
Prevent Varnish from creating cache variations of static files
  • Loading branch information
kokoc committed Jan 22, 2015
2 parents ae761e3 + dcb3c67 commit 1e45a1e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/code/Magento/PageCache/etc/varnish.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ sub vcl_recv {
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}

# normalize url in case of leading HTTP scheme and domain
set req.url = regsub(req.url, "^http[s]?://[^/]+", "");

# collect all cookies
std.collect(req.http.Cookie);

# static files are always cacheable. remove SSL flag and cookie
if (req.url ~ "^/(pub/)?(media|static)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico|woff|svg)$") {
unset req.http.Https;
unset req.http.Cookie;
}

set req.grace = 1m;

Expand Down

0 comments on commit 1e45a1e

Please sign in to comment.