Topic 089 / Core
Content delivery networks: push vs pull, edge caching
Chapter 6.2 · Distributed Caching and CDNs
What and why
A CDN applies caching fundamentals (→ 82) at internet scale: static and semi-static content is served from points of presence (PoPs) near the user instead of a single origin, cutting both distance-driven latency and origin load. Pull means the CDN fetches from the origin on first miss — the default, following the hierarchy's usual miss-forwards-down rule. Push means the operator uploads content to the CDN ahead of any demand. Builds on: → 82 (caching fundamentals: cache hierarchy, hit ratio).
Diagram
Text version of this diagram
PULL (default) PUSH
─────────────── ────
user ──► nearest edge PoP operator ──► uploads once ──► all PoPs
│ miss (first request only) (content pre-populated before
▼ any user asks)
origin ──► edge caches the response
│
user ◄── edge serves every request after the first
How it works
- Pull: the first request for an object at a given PoP misses, the CDN fetches it from the origin, caches it at that edge, and serves every later request from the edge — the hierarchy's miss-forwards-down rule (→ 82), with the origin as the last layer.
- Push: the operator uploads content to the CDN proactively, before any user request — every PoP already holds it, so even the first request at any PoP is a hit.
- Origin shielding adds one more layer between edge PoPs and the origin: a smaller set of shield caches absorbs the first-miss traffic from many edges, so the origin sees one request per object, not one per PoP.
- The cache key determines what counts as "the same object" — typically the URL plus selected headers or query parameters; the key design directly controls hit ratio.
- Freshness is managed by TTL/cache-control headers (→ 85), by explicit purge (an operator-triggered invalidation), or by versioned URLs — baking a content hash or version into the URL so a changed file is simply a new URL, never purged.
Practical example
(numbers illustrative). An origin serves a thumbnail to 1,000,000 requests/day from a single region at 150 ms average latency. With a pull-based CDN across 50 PoPs, the first request per PoP still costs 150 ms, but the remaining 999,950 requests are served locally at ~15 ms. Mean latency = (50×150 + 999,950×15) ÷ 1,000,000 = (7,500 + 14,999,250) ÷ 1,000,000 ≈ 15.0 ms, and origin traffic drops from 1,000,000 requests/day to 50.
When to use it
- Use pull for most content — simple, self-managing, only fetches what's actually requested.
- Use push for predictable, large, or launch-critical assets (a game patch, a launch video) where the first-request miss at every PoP simultaneously would be unacceptable.
- Avoid CDN caching for highly personalized or rapidly changing per-request responses — low hit ratio, the same "nothing to cache profitably" case as → 82.
- Failure scenarios: a purge issued but not propagated to every PoP in time, serving stale content from some edges and fresh from others at once; a cache key omitting a header that actually varies the response (serving one user's personalized page to another); origin overload the instant a cache is flushed or a deploy changes every cache key at once (a stampede at CDN scale, → 88).
- Simpler alternative: for small, low-traffic sites, no CDN at all — a single well-placed origin with HTTP caching headers may already meet the latency target.
Practice
(paper/trace exercise — no single lab service models a multi-PoP CDN; 15–20 min).
- Re-trace the pull-based example above with 20 PoPs instead of 50 and confirm the mean latency by recomputing.
- Decide push, pull, or no-CDN for each of: a product image, a per-user shopping cart page, a 10 GB game patch released at a fixed time — justify each from its traffic pattern.
- Design a cache key for an API response that varies by
Accept-Languageand region but not by auth token; write out exactly what the key must include.
Done when your 20-PoP recomputation matches direct arithmetic, not an estimate.
Shared lab setupKey takeaway
A CDN is the outermost layer of the cache hierarchy (→ 82), with the same hit/miss trade-off; push vs. pull decides whether the first miss happens at launch time or at first request. Done when you can: compute a CDN's blended latency and origin load from PoP count and per-tier latencies, and design a correct cache key for a given response. Used next in → 94 (global traffic routing, getting requests to the right PoP); Project 18 (CDN delivery).
References
None — this topic makes no external claims.
Source directory