File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
app/code/Magento/PageCache/etc Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,18 @@ sub vcl_backend_response {
180180
181181 # validate if we need to cache it and prevent from setting cookie
182182 if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD" )) {
183+ # Collapse beresp.http.set-cookie in order to merge multiple set-cookie headers
184+ # Although it is not recommended to collapse set-cookie header,
185+ # it is safe to do it here as the set-cookie header is removed below
186+ std.collect (beresp.http.set-cookie );
187+ # Do not cache the response under current cache key (hash),
188+ # if the response has X-Magento-Vary but the request does not.
189+ if ((bereq.url !~ "/graphql" || ! bereq.http.X-Magento-Cache-Id )
190+ && bereq.http.cookie !~ "X-Magento-Vary="
191+ && beresp.http.set-cookie ~ "X-Magento-Vary=" ) {
192+ set beresp.ttl = 0s ;
193+ set beresp.uncacheable = true ;
194+ }
183195 unset beresp.http.set-cookie ;
184196 }
185197
Original file line number Diff line number Diff line change @@ -179,6 +179,18 @@ sub vcl_backend_response {
179179
180180 # validate if we need to cache it and prevent from setting cookie
181181 if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD" )) {
182+ # Collapse beresp.http.set-cookie in order to merge multiple set-cookie headers
183+ # Although it is not recommended to collapse set-cookie header,
184+ # it is safe to do it here as the set-cookie header is removed below
185+ std.collect (beresp.http.set-cookie );
186+ # Do not cache the response under current cache key (hash),
187+ # if the response has X-Magento-Vary but the request does not.
188+ if ((bereq.url !~ "/graphql" || ! bereq.http.X-Magento-Cache-Id )
189+ && bereq.http.cookie !~ "X-Magento-Vary="
190+ && beresp.http.set-cookie ~ "X-Magento-Vary=" ) {
191+ set beresp.ttl = 0s ;
192+ set beresp.uncacheable = true ;
193+ }
182194 unset beresp.http.set-cookie ;
183195 }
184196
Original file line number Diff line number Diff line change @@ -183,6 +183,18 @@ sub vcl_backend_response {
183183
184184 # validate if we need to cache it and prevent from setting cookie
185185 if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD" )) {
186+ # Collapse beresp.http.set-cookie in order to merge multiple set-cookie headers
187+ # Although it is not recommended to collapse set-cookie header,
188+ # it is safe to do it here as the set-cookie header is removed below
189+ std.collect (beresp.http.set-cookie );
190+ # Do not cache the response under current cache key (hash),
191+ # if the response has X-Magento-Vary but the request does not.
192+ if ((bereq.url !~ "/graphql" || ! bereq.http.X-Magento-Cache-Id )
193+ && bereq.http.cookie !~ "X-Magento-Vary="
194+ && beresp.http.set-cookie ~ "X-Magento-Vary=" ) {
195+ set beresp.ttl = 0s ;
196+ set beresp.uncacheable = true ;
197+ }
186198 unset beresp.http.set-cookie ;
187199 }
188200
You can’t perform that action at this time.
0 commit comments