Course map

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

CDN: pull vs push Pull: the user requests the nearest edge PoP, which misses on the first request only, fetches from the origin, caches the response, and from then on serves every request itself. Push: the operator uploads content once and it is pre-populated at all PoPs before any user asks. PULL (default) User Edge PoP Origin 1 request 2 miss (first request only) caches the response 3 serves every request after the first PUSH Operator All PoPs uploads once content pre-populated before any user asks
Origin shielding adds a layer between edge PoPs and the origin that absorbs first-miss traffic, so the origin sees one request per object, not one per PoP. Freshness is managed by TTL/cache-control, explicit purge, or versioned URLs — baking a version into the URL so a changed file is simply a new URL, never purged.
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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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).

  1. Re-trace the pull-based example above with 20 PoPs instead of 50 and confirm the mean latency by recomputing.
  2. 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.
  3. Design a cache key for an API response that varies by Accept-Language and 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 setup

Key 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

Search the guide