@@ -145,28 +145,31 @@ sub vcl_backend_response {
145
145
set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control ;
146
146
}
147
147
148
+ # cache only successfully responses and 404s
149
+ if (beresp.status != 200 && beresp.status != 404 ) {
150
+ set beresp.ttl = 0s ;
151
+ set beresp.uncacheable = true ;
152
+ return (deliver );
153
+ } elsif (beresp.http.Cache-Control ~ " private" ) {
154
+ set beresp.uncacheable = true ;
155
+ set beresp.ttl = 86400s ;
156
+ return (deliver );
157
+ }
158
+
148
159
# validate if we need to cache it and prevent from setting cookie
149
160
if (beresp.ttl > 0s && (bereq.method == " GET" || bereq.method == " HEAD" )) {
150
161
unset beresp.http.set-cookie ;
151
162
}
152
163
153
- # cache only successfully responses and 404s
154
- if (beresp.status != 200 && beresp.status != 404 ) {
155
- set beresp.ttl = 0s ;
156
- set beresp.uncacheable = true ;
157
- } elseif (beresp.ttl <= 0s ||
158
- beresp.http.Surrogate-control ~ " no-store" ||
159
- (!beresp.http.Surrogate-Control &&
160
- beresp.http.Cache-Control ~ " no-cache|no-store" ||
161
- beresp.http.Vary == " *" )
162
- ) {
163
- # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
164
- # Mark as Hit-For-Pass for the next 2 minutes
164
+ # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
165
+ if (beresp.ttl <= 0s ||
166
+ beresp.http.Surrogate-control ~ " no-store" ||
167
+ (!beresp.http.Surrogate-Control &&
168
+ beresp.http.Cache-Control ~ " no-cache|no-store" ) ||
169
+ beresp.http.Vary == " *" ) {
170
+ # Mark as Hit-For-Pass for the next 2 minutes
165
171
set beresp.ttl = 120s ;
166
172
set beresp.uncacheable = true ;
167
- } elsif (beresp.http.Cache-Control ~ " private" ) {
168
- set beresp.uncacheable = true ;
169
- set beresp.ttl = 86400s ;
170
173
}
171
174
172
175
return (deliver );
0 commit comments