Skip to content

Commit 5876364

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-83152: [github] Pages are cached in browser and not updated
1 parent 033e9c1 commit 5876364

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,14 @@ sub vcl_backend_response {
157157
}
158158

159159
# validate if we need to cache it and prevent from setting cookie
160+
# images, css and js are cacheable by default so we have to remove cookie also
160161
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
161162
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+
}
162168
}
163169

164170
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,14 @@ sub vcl_backend_response {
158158
}
159159

160160
# validate if we need to cache it and prevent from setting cookie
161+
# images, css and js are cacheable by default so we have to remove cookie also
161162
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
162163
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+
}
163169
}
164170

165171
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass

0 commit comments

Comments
 (0)