Skip to content

Commit d9ebeee

Browse files
Merge pull request #1758 from magento-qwerty/2.2.2-develop-PR
Fixed issues: - MAGETWO-83152: [github] Pages are cached in browser and not updated
2 parents e5ebb5a + 1a4e4a2 commit d9ebeee

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ 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;
162163
}
@@ -187,6 +188,13 @@ sub vcl_deliver {
187188
unset resp.http.Age;
188189
}
189190

191+
# Not letting browser to cache non-static files.
192+
if (resp.http.Cache-Control !~ "private" && 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+
190198
unset resp.http.X-Magento-Debug;
191199
unset resp.http.X-Magento-Tags;
192200
unset resp.http.X-Powered-By;

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ 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;
163164
}
@@ -188,6 +189,13 @@ sub vcl_deliver {
188189
unset resp.http.Age;
189190
}
190191

192+
# Not letting browser to cache non-static files.
193+
if (resp.http.Cache-Control !~ "private" && 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+
191199
unset resp.http.X-Magento-Debug;
192200
unset resp.http.X-Magento-Tags;
193201
unset resp.http.X-Powered-By;

0 commit comments

Comments
 (0)