Skip to content

Commit 651e652

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-33342' into pr-develop
2 parents ae53ec1 + 1c77156 commit 651e652

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,15 @@ sub vcl_recv {
9696
set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
9797
set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
9898

99-
# static files are always cacheable. remove SSL flag and cookie
100-
if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|html|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") {
101-
unset req.http.Https;
102-
unset req.http./* {{ ssl_offloaded_header }} */;
103-
unset req.http.Cookie;
99+
# Static files caching
100+
if (req.url ~ "^/(pub/)?(media|static)/.*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|html|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|tiff|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)$") {
101+
# Static files should not be cached by default
102+
return (pass);
103+
104+
# But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
105+
#unset req.http.Https;
106+
#unset req.http./* {{ ssl_offloaded_header }} */;
107+
#unset req.http.Cookie;
104108
}
105109

106110
return (hash);
@@ -156,7 +160,7 @@ sub vcl_backend_response {
156160
# images, css and js are cacheable by default so we have to remove cookie also
157161
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
158162
unset beresp.http.set-cookie;
159-
if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") {
163+
if (bereq.url !~ "\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|html|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|tiff|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?|$)") {
160164
set beresp.http.Pragma = "no-cache";
161165
set beresp.http.Expires = "-1";
162166
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ sub vcl_recv {
9797
set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
9898
set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
9999

100-
# static files are always cacheable. remove SSL flag and cookie
101-
if (req.url ~ "^/(pub/)?(media|static)/.*\.(ico|html|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$") {
102-
unset req.http.Https;
103-
unset req.http./* {{ ssl_offloaded_header }} */;
104-
unset req.http.Cookie;
100+
# Static files caching
101+
if (req.url ~ "^/(pub/)?(media|static)/.*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|html|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|tiff|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)$") {
102+
# Static files should not be cached by default
103+
return (pass);
104+
105+
# But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
106+
#unset req.http.Https;
107+
#unset req.http./* {{ ssl_offloaded_header }} */;
108+
#unset req.http.Cookie;
105109
}
106110

107111
return (hash);
@@ -157,7 +161,7 @@ sub vcl_backend_response {
157161
# images, css and js are cacheable by default so we have to remove cookie also
158162
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
159163
unset beresp.http.set-cookie;
160-
if (bereq.url !~ "\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\?|$)") {
164+
if (bereq.url !~ "\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|html|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|tiff|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?|$)") {
161165
set beresp.http.Pragma = "no-cache";
162166
set beresp.http.Expires = "-1";
163167
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";

0 commit comments

Comments
 (0)