What I Learned: A Cache Is a Chain, Not a Box
A cache is a chain, not a box. Three lessons from chasing a CDN cache loop, and three questions to ask at every layer a request passes through.
In interviews I only said “add a CDN layer and it gets faster.” After this chase, I can read every cache layer that a request passes.
Three Things I Understand Now
- Every component has its own cache setting: the TTL passes from storage to the client and can only go down on the way. If IaC does not say it, it does not mean there is no setting. The defaults are always there (TTL Is Set in Three Places).
- A tiered cache and an LB cache are two different things: a tiered cache is the second layer inside the CDN. The LB cache sits on our own origin. The CDN cannot skip it, and a purge cannot reach it (CDN Terms on One Page, Two Cache Layers: What I Believed).
- A custom header works only where a rule reads it:
X-Cache-Bypassand the proxy header are not HTTP standards. A component with no rule to read them simply ignores them (Cache Headers: Who Sets, Who Reads, A Bypass Header Works Only Where a Rule Reads It).
What This Chase Brought
- I turned the findings into one direction: lower the cost and raise the serving performance at the same time.
- I proposed this direction to the team. With fewer duplicate caches and failed refreshes, the origin gets fewer requests, and users load pages faster.
- Lower cost and faster loads help the team and the revenue of the company.
The biggest gain was not finding one bug. It was learning to follow one request along the whole path (Five Parts Make One Loop). At each layer, I ask three questions:
- Is there a cache here?
- Which headers does it read?
- Can a purge reach it?
A cache is not a box. It is a chain, and each link has its own rules.
Related: CDN Terms on One Page, Cache Headers: Who Sets, Who Reads, Two Cache Layers: What I Believed, TTL Is Set in Three Places, A Bypass Header Works Only Where a Rule Reads It, Five Parts Make One Loop. Or go back to the series overview.