From 1f3737b72522f120eceff7613f0390516a5367e3 Mon Sep 17 00:00:00 2001 From: PhoenixPM - BK Date: Wed, 21 Jan 2015 11:50:49 +0100 Subject: [PATCH] prevent several cache versions for static files because of X-Magento-Vary cookie --- app/code/Magento/PageCache/etc/varnish.vcl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/code/Magento/PageCache/etc/varnish.vcl b/app/code/Magento/PageCache/etc/varnish.vcl index 4b2a337ba321f..7929214655501 100644 --- a/app/code/Magento/PageCache/etc/varnish.vcl +++ b/app/code/Magento/PageCache/etc/varnish.vcl @@ -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 ~ "^/(media|js|skin)/.*\.(png|jpg|jpeg|gif|css|js|swf|ico)$") { + unset req.http.Https; + unset req.http.Cookie; + } set req.grace = 1m;