Skip to main content

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-Control header is set to private, no-store, no-cache, or max-age=0 or if there is a cookie in the response.
  • Cloudflare caches the resource in the following scenarios:
    • The Cache-Control header is set to public and the max-age is greater than 0.
    • The Expires header is set to a future date.
  • If both the max-age and an Expires header are set, max-age is used.

- Rapha.cc:

Rapha path containing GraphQL

  • Rapha and uat.rapha caching:

    • https://www.rapha.cc/graphql/ returns GET query missing. Guess our catalogue data is stored here when queried?

    • https://www.rapha.cc/graphql errors (see below).

Rapha graphql wrong path

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

Rapha hosts starting with GraphQL

- Raphadev.cc:

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

RaphaDev path containing GraphQL

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

RaphaDev hosts starting with GraphQL

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.

rapha.cc

  • 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.

preprod.rapha

- 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

ci.raphadev

--

Resources