Skip to content

Commit dee14ee

Browse files
author
Prabhu Ram
committed
MC-31987: Varnish graphql cache has to skip authenticated requests
- review fix
1 parent 19b9bfb commit dee14ee

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ sub vcl_recv {
108108
#unset req.http.Cookie;
109109
}
110110

111-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=" && req.http.Authorization ~ "^Bearer") {
112-
# Authentificated customers should not be cached by default
113-
return (pass);
111+
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=") {
112+
# Authentificated customers should not be cached by default
113+
if (req.http.Authorization ~ "^Bearer") {
114+
return (pass);
115+
}
114116
}
115117

116118
return (hash);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ sub vcl_recv {
109109
#unset req.http.Cookie;
110110
}
111111

112-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=" && req.http.Authorization ~ "^Bearer") {
113-
# Authentificated customers should not be cached by default
114-
return (pass);
112+
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=") {
113+
# Authentificated customers should not be cached by default
114+
if (req.http.Authorization ~ "^Bearer") {
115+
return (pass);
116+
}
115117
}
116118

117119
return (hash);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ sub vcl_recv {
109109
#unset req.http.Cookie;
110110
}
111111

112-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=" && req.http.Authorization ~ "^Bearer") {
112+
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=") {
113113
# Authentificated customers should not be cached by default
114-
return (pass);
114+
if (req.http.Authorization ~ "^Bearer") {
115+
return (pass);
116+
}
115117
}
116118

117119
return (hash);

0 commit comments

Comments
 (0)