Lab · Building blocks
CDN and edge caching
Users in three regions fetch files through a nearby edge cache. The origin sits in the US. See how popularity, TTL and cache size set the hit rate, what a purge does, and how an origin shield protects the origin.
Try it
The lab is busy, so only some requests are drawn as dots, few enough to follow. The numbers still count every request.
- US — 20 requests/s — healthy
- US edge — hit rate 49% — healthy — 20/20 files
- Europe — 20 requests/s — healthy
- Europe edge — hit rate 62% — healthy — 20/20 files
- Asia — 20 requests/s — healthy
- Asia edge — hit rate 61% — healthy — 20/20 files
- Origin (US) — holds every file — healthy — 18 fetches/s
- Request
- Edge hit
- Edge miss → origin
- Answer after a miss
Hit rate
58%
Origin fetches
18/s
Average wait · US
61 ms
Average wait · Europe
73 ms
Average wait · Asia
98 ms
Purges
0
Numbers add up:201 requests = 117 hits + 84 misses; misses = 84 origin fetches + 0 shield hitsThe lab checks this sum as it runs, so a counting mistake would show here.
Controls
Follow a request
Pause to pick a request that is on screen.
By region
| Region | Hit rate | Average wait | Files cached | Trip to origin |
|---|---|---|---|---|
| US | 49% | 61 ms | 20 of 20 | 30 ms |
| Europe | 62% | 73 ms | 20 of 20 | 90 ms |
| Asia | 61% | 98 ms | 20 of 20 | 150 ms |
A miss in Asia costs the most, because Asia is farthest from the origin. Hits cost the same 20 ms everywhere.
Show data table
| Time | Hit rate |
|---|---|
| 1s | 19% |
| 1s | 26% |
| 2s | 43% |
| 2s | 49% |
| 3s | 54% |
| 3s | 58% |
Show data table
| Time | Origin fetches/s |
|---|---|
| 1s | 42 |
| 1s | 45 |
| 2s | 38 |
| 2s | 21 |
| 3s | 17 |
| 3s | 18 |
What just happened
- 0.0sInfo: Every edge starts empty. Each keeps up to 20 files for 30 s.
What this model simplifies
- Round trips are fixed and illustrative: 20 ms to the nearby edge, and 30, 90 or 150 ms from each edge to the origin. Real networks vary.
- Time is slowed so you can watch each request. The share of hits and misses is what matters here.
- Two misses for the same file at the same moment each go to the origin. Real CDNs often combine them into one fetch.
- Each region has one edge, and every file has the same size. Real CDNs run hundreds of edges and cache files of very different sizes.
- A copy counts its TTL from when this cache stored it. A copy from the shield starts a new TTL, so a file can be up to twice the TTL old. Real CDNs pass on the copy's age.
- Changing the TTL also changes copies already stored. The shield has room for three edges' worth of files, which here is every file.