Use POST for eTag caching GraphQL
What does this MR do and why?
GraphQL queries use a GET request for eTag caching to allow the browser to do a lot of the heavy lifting. This causes issues for customers who self-host and have strict limits from providers like AWS WAF where if a query string is too long the request will not complete. This MR moves eTag caching over to POST requests and builds a util function to do what the browser did for us with GET requests.
Locations
Currently eTag caching with GraphQL is used for 5 routes that can be seen here lib/gitlab/etag_caching/router/graphql.rb
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
-
Enable feature flag
etag_caching_post_requests -
Open the project's Build > Pipelines page, then open DevTools > Network and filter on
graphql.- Look for: a
POSTto/api/graphqlwith no query string. The Payload tab showsoperationName: getPipelines. Request headers includex-gitlab-graphql-resource-etag: /api/graphql:project_pipelines/<id>. The response is200with anetagheader, and the request has noif-none-match.
- Look for: a
-
Wait about 60 seconds for the next poll, without changing anything.
- Look for: the request sends
if-none-matchequal to the previousetag. The response is304withx-gitlab-from-cache: trueand a very lowx-runtime(tens of ms). The pipeline list stays on screen with no "An error occurred while loading pipelines".
- Look for: the request sends
-
Start or retry a pipeline, then wait for the next poll.
- Look for: the request sends the old
if-none-match. The response is200with a newetag, nox-gitlab-from-cache, and a higherx-runtime. The list updates.
- Look for: the request sends the old
-
Wait for another poll once the pipeline stops changing.
- Look for: the request sends the latest
etag, and the response is304withx-gitlab-from-cache: trueagain.
- Look for: the request sends the latest
-
Switch to another tab (for example Finished) or go to the next page of results.
- Look for: the first request for that tab or page has no
if-none-match, because each set of variables gets its own cache entry.
- Look for: the first request for that tab or page has no
-
Open a pipeline's details page.
- Look for: the same
POSTand304pattern on requests withx-gitlab-graphql-resource-etag: /api/graphql:pipelines/id/<id>.
- Look for: the same
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #618236