Skip to main content

Current Cloudflare Caching

There are two places within the Cloudflare ecosystem that we can define caching configuration:-

  1. Page Rules
  2. Caching Configuration

It should be noted that Cloudflare only caches assets that traverse through it's data centres, which in the context of Rapha means any asset that is accessed via a *.rapha.cc or *.raphadev.cc URL.

Page Rules

There are four page rules which currently modify caching behaviour.

  1. www.rapha.cc/* - Origin Cache Control = Off

    • This page rule means that Cloudflare doesn't necessarily respect the cache controls defined by Rapha's servers.
    • This generally just means that assets from these URL's are retained for longer by Cloudflare than they would otherwise be.
  2. www.rapha.cc/* - Rocket Loader = On

    • This page rule being enabled ensures that on pages that match this rule assets, such as fonts, images & text, will render BEFORE any javascript executes.
    • Although this isn't strictly cache related, it is dependent on the cache so is included here.
  3. www.rapha.cc/*/category/* - Cache Everything, Cache TTL = 20 mins, Bypass Cache on JSESSIONID, Cache on Device Type

    • This rule can be defined as meaning the following:-
      • All assets from any category page are cached
      • The cache is refreshed every 20 minutes
      • Assets for specific devices (e.g. iPad, iPhone11 etc) are stored as distinct items in the cache and returned based on the device pulling from the cache.
      • If a user has a JSESSIONID cookie present, which happens when a user has an active cart, then the cache is bypassed and assets are returned from the origin server.
  4. static.rapha.cc/* - Lossy Polish, Cache Everything, Cache TTL = 28 days, Header Override = i1.adis.ws

    • This rule can be defined as meaning the following:-
      • All assets from this URL are cached
      • All images from this URL are compressed using lossy compression
      • The cache is refreshed every 28 days.
      • Any asset pulled from this URL, is actually pulling from Ampliences image resizer engine.

Caching Configuration

There are two settings which impact the cache within the configuration section:

  1. Caching Level = Standard

    • This effectively sets the cache up in such a way that it will return the same resource if a path including query string is the same.
    • If the query string differs, then a different asset will be returned from the cache.
    • As before, the cache is only applicable to content that passes through Cloudflare's data centre (i.e. anything with *.rapha.cc as its URL)
  2. Browser Cache TTL = 2 Days

    • This tells the users browser to cache assets from Rapha URL's for at least 2 days.
    • This ensures that even if we set a cache control header on an asset on a rapha.cc URL, it will always be cached for 2 days at minimum.