Skip to content

Commit 6cda42a

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-83152: [github] Pages are cached in browser and not updated
1 parent 06f028e commit 6cda42a

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ sub vcl_backend_response {
160160
# images, css and js are cacheable by default so we have to remove cookie also
161161
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
162162
unset beresp.http.set-cookie;
163-
if (bereq.url !~ "\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|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)(\?|$)") {
164-
set beresp.http.Pragma = "no-cache";
165-
set beresp.http.Expires = "-1";
166-
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
167-
}
168163
}
169164

170165
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
@@ -193,6 +188,13 @@ sub vcl_deliver {
193188
unset resp.http.Age;
194189
}
195190

191+
# Not letting browser to cache non-static files.
192+
if (req.url !~ "^/(pub/)?(media|static)/") {
193+
set resp.http.Pragma = "no-cache";
194+
set resp.http.Expires = "-1";
195+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
196+
}
197+
196198
unset resp.http.X-Magento-Debug;
197199
unset resp.http.X-Magento-Tags;
198200
unset resp.http.X-Powered-By;

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ sub vcl_backend_response {
161161
# images, css and js are cacheable by default so we have to remove cookie also
162162
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
163163
unset beresp.http.set-cookie;
164-
if (bereq.url !~ "\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|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)(\?|$)") {
165-
set beresp.http.Pragma = "no-cache";
166-
set beresp.http.Expires = "-1";
167-
set beresp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
168-
}
169164
}
170165

171166
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
@@ -194,6 +189,13 @@ sub vcl_deliver {
194189
unset resp.http.Age;
195190
}
196191

192+
# Not letting browser to cache non-static files.
193+
if (req.url !~ "^/(pub/)?(media|static)/") {
194+
set resp.http.Pragma = "no-cache";
195+
set resp.http.Expires = "-1";
196+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
197+
}
198+
197199
unset resp.http.X-Magento-Debug;
198200
unset resp.http.X-Magento-Tags;
199201
unset resp.http.X-Powered-By;

0 commit comments

Comments
 (0)