Spike - Investigate Cloudflare Caching
Overview
Results from a spike looking into cloudflare caching for GraphQL. The aim of the spike is to review what is being cached in cloudflare and be sure we don't cache things that should not be cached.
What is being cached in CL?
Cloudflare respects the origin web server’s cache headers in the following order unless an Edge Cache TTL page rule overrides the headers.
- Cloudflare does not cache the resource if the
Cache-Controlheader is set toprivate,no-store,no-cache, ormax-age=0or if there is a cookie in the response. - Cloudflare caches the resource in the following scenarios:
- The
Cache-Controlheader is set topublicand themax-ageis greater than 0. - The
Expiresheader is set to a future date.
- The
- If both the
max-ageand anExpiresheader are set,max-ageis used.
- Rapha.cc:

Rapha and uat.rapha caching:
https://www.rapha.cc/graphql/returnsGET query missing.Guess our catalogue data is stored here when queried?https://www.rapha.cc/graphqlerrors (see below).

- Apollo server health: Right now, we are caching Apollo’s Health Checks on rapha.cc. This should NEVER be cached:

- Raphadev.cc:
- Sourcegraph caching: Returns
Private mode requires authentication.Not sure what is being cached here.

- Apollo server health: Right now, we are caching Apollo’s Health Checks on raphadev.cc. This should NEVER be cached:

Page rules for GarphQL
(Is Cloudflare currently caching anything for the GraphQL URL? - This should be configured under Cloudflare Page Rules)
- Rapha.cc:
- Main website GraphQL re-routing: This setting changes the DNS lookup for the request such that it is routed to a different origin IP address than it would be normally. Note that Resolve Override does not rewrite the request in any way; it only routes it to a different server.

- Preprod GraphQL re-routing: This setting changes the DNS lookup for the request such that it is routed to a different origin IP address than it would be normally. Note that Resolve Override does not rewrite the request in any way; it only routes it to a different server.

- Raphadev.cc:
- Ci.raphadev: We cache everything for raphadev with a Brower cache/Edgye cache TTL of a minute as well as a re-routing

--
Resources
- https://developers.cloudflare.com/docs/
- https://support.cloudflare.com/hc/en-us/categories/200276257-Page-Rules
- https://developers.cloudflare.com/cache/
- https://dash.cloudflare.com/52c66ac5aa81ef4bbb64b37dda6b27d4/raphadev.cc/caching
- https://dash.cloudflare.com/52c66ac5aa81ef4bbb64b37dda6b27d4/rapha.cc/caching