Skip to content

Commit 1e45a1e

Browse files
committed
Merge pull request #988 from PHOENIX-MEDIA/fix-vary-on-static-files
Prevent Varnish from creating cache variations of static files
2 parents ae761e3 + dcb3c67 commit 1e45a1e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/code/Magento/PageCache/etc/varnish.vcl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ sub vcl_recv {
4646
if (req.request != "GET" && req.request != "HEAD") {
4747
return (pass);
4848
}
49+
50+
# normalize url in case of leading HTTP scheme and domain
51+
set req.url = regsub(req.url, "^http[s]?://[^/]+", "");
52+
53+
# collect all cookies
54+
std.collect(req.http.Cookie);
55+
56+
# static files are always cacheable. remove SSL flag and cookie
57+
if (req.url ~ "^/(pub/)?(media|static)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico|woff|svg)$") {
58+
unset req.http.Https;
59+
unset req.http.Cookie;
60+
}
4961

5062
set req.grace = 1m;
5163

0 commit comments

Comments
 (0)