# Cache warming and tiered caching

> Fill a cache before it takes traffic, and put a second cache between the first and the origin, so a cold or distant cache does not send every read to the source.

Warming fills a cache ahead of demand, and tiering lets a miss ask a nearby cache before it asks the origin.

## Use it when

- A cache restart or a deploy leaves the database overloaded for minutes.
- Many CDN edges miss the same large file and each fetches it from your origin.
- You know what will be hot before it is requested, such as a launch page.

## How it works

Warming replays recent or popular keys into the cache before it receives users. Tools do this by reading a key list from the database, or by loading a snapshot, as Redis does when it reloads its data file after a restart.

Tiering adds a layer. A CDN edge that misses asks a regional cache, and only that cache calls the origin. Ten edges missing the same video cost the origin one fetch, not ten. Cloudflare and Fastly both sell this as a shield or tiered cache.

## What it costs

Warming takes time and database reads of its own, so a warm-up run during peak hours can cause the load it was meant to prevent. A stale key list warms the wrong data. Tiering adds a hop on a miss and one more cache to purge, so a purge that reaches only the edge leaves old content in the regional tier.

## In Quorum

Warming is a switch on the [Cache](https://wiki.playquorum.dev/components/cache.md), and it needs [Cache warming](https://wiki.playquorum.dev/research/cache-warming.md), which in turn needs [Stampede protection](https://wiki.playquorum.dev/research/stampede-protection.md). Tiered caching is a [CDN](https://wiki.playquorum.dev/components/cdn.md) effect with no switch: [Tiered caching](https://wiki.playquorum.dev/research/tiered-caching.md) makes edges ask a regional tier for video, and the Design lists it as a research it needs.



The [Cache stampede](https://wiki.playquorum.dev/incidents/stampede.md) incident is what warming prevents. The glossary defines [cache warming](https://wiki.playquorum.dev/glossary/cache-warming.md) and [tiered caching](https://wiki.playquorum.dev/glossary/tiered-caching.md).

Source: https://wiki.playquorum.dev/patterns/cache-warming-and-tiered-caching
