Skip to content

Commit de81e62

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

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

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

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

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

118116
return (hash);
@@ -130,7 +128,7 @@ sub vcl_hash {
130128
hash_data(server.ip);
131129
}
132130

133-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=") {
131+
if (req.url ~ "/graphql") {
134132
call process_graphql_headers;
135133
}
136134

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

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

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

119117
return (hash);
@@ -137,7 +135,7 @@ sub vcl_hash {
137135
}
138136
/* {{ design_exceptions_code }} */
139137

140-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=" ) {
138+
if (req.url ~ "/graphql") {
141139
call process_graphql_headers;
142140
}
143141
}

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

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

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

119117
return (hash);
@@ -137,7 +135,7 @@ sub vcl_hash {
137135
}
138136
/* {{ design_exceptions_code }} */
139137

140-
if (req.method == "GET" && req.url ~ "/graphql" && req.url ~ "query=") {
138+
if (req.url ~ "/graphql") {
141139
call process_graphql_headers;
142140
}
143141
}

0 commit comments

Comments
 (0)