Skip to content

Commit ce87aa4

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'ext/MAGETWO-54228-Varnish-cache-disabled' into pull-request
2 parents 1164adc + 8ac29f0 commit ce87aa4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ sub vcl_recv {
4949
return (pass);
5050
}
5151

52-
# Bypass shopping cart and checkout requests
53-
if (req.url ~ "/checkout") {
52+
# Bypass shopping cart, checkout and search requests
53+
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
5454
return (pass);
5555
}
5656

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ sub vcl_recv {
4141
return (pass);
4242
}
4343

44-
# Bypass shopping cart and checkout requests
45-
if (req.url ~ "/checkout") {
44+
# Bypass shopping cart, checkout and search requests
45+
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
4646
return (pass);
4747
}
4848

@@ -136,6 +136,16 @@ sub vcl_backend_response {
136136
set beresp.grace = 1m;
137137
}
138138
}
139+
140+
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
141+
if (beresp.ttl <= 0s ||
142+
beresp.http.Surrogate-control ~ "no-store" ||
143+
(!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) {
144+
# Mark as Hit-For-Pass for the next 2 minutes
145+
set beresp.ttl = 120s;
146+
set beresp.uncacheable = true;
147+
}
148+
return (deliver);
139149
}
140150

141151
sub vcl_deliver {

0 commit comments

Comments
 (0)