Skip to content

Lesson 8 of 9 · 26m

CDN Architecture, Cache Keys, and Origin Protection

Design object layout, TTLs, cache keys, shielding, authentication, and invalidation so popular video scales without turning every miss into an origin incident.

A CDN is not a magic bandwidth coupon. It is a distributed cache whose behavior you must design. Video magnifies every caching mistake because objects are large, audiences synchronize around events, and manifests have completely different freshness requirements from media segments.

Separate control-plane freshness from data-plane immutability

Manifests change during live playback. Segments generally do not. Their cache policy should reflect that difference:

live playlists      cache-control: max-age=1 or very short TTL
VOD playlists       often short-to-medium TTL if metadata may be corrected
media/init segments long TTL, immutable, versioned object names
license endpoints   no CDN caching of user-specific authorization responses

Long-lived media objects should have unique names when content changes. Do not overwrite segment_00042.m4s and expect global caches to agree about which version exists.

Cache keys determine hit ratio

A cache key is the set of request properties the CDN uses to decide whether two requests are the same object. If you sign playback URLs with query parameters, naively including the full query string fragments the cache: every user receives a different key for the same segment. Normalize deliberately. Either exclude validated signatures from the cache key after auth enforcement or move authorization into a mechanism compatible with your CDN's caching model.

good key inputs    host, normalized path, necessary protocol/codec variation
dangerous inputs   signed token query, cache-buster, default user agent; sometimes device/experiment/region

Every unnecessary variation multiplies origin fetches, storage pressure at the edge, and tail latency.

Use shielding for synchronized demand

Live events create simultaneous cache misses. When thousands of edge nodes request the newest segment at once, an origin shield or mid-tier cache can collapse many misses into one upstream request:

viewers -> edge POPs -> regional shield -> origin/object storage

Without shielding, the newest segment is paradoxically the most dangerous object because it is both hot and initially uncached. Request collapsing inside a POP helps, but cross-POP amplification can still hurt. Know how your CDN behaves rather than assuming.

Origin protection is a load-bearing control

The origin should not be publicly writable by arbitrary playback clients, should authenticate CDN pulls where appropriate, and should have rate and concurrency protection. Monitor origin offload:

offload = bytes served from cache / total viewer bytes

A drop in offload during a traffic spike means the edge is no longer absorbing demand exactly when you need it most. Pair that with time-to-first-byte, origin 5xx rate, retry behavior, and per-object-family hit ratio. Aggregate hit ratio can hide the fact that manifests hit perfectly while large segments miss constantly.

Invalidation is not a scaling strategy

If you routinely purge huge object families, your naming and versioning model is wrong. Use versioned paths for replacement and short TTLs for genuinely mutable manifests. Invalidation is appropriate for emergency correction, not routine publication.

Multi-CDN starts with consistent contracts

Before splitting traffic across providers, normalize URLs, token behavior, cache key rules, header handling, TLS policy, logging, and purge semantics. If each CDN interprets the content path differently, traffic steering becomes a cache-fragmentation machine. Multi-CDN is an operational discipline first and a procurement exercise second.

Field notes

  • Test cache behavior with curl -I and repeated requests, but remember POPs differ; one probe is not global truth.
  • Keep signed URL expiry aligned with segment duration and session length. Expiring mid-playback creates avoidable failures.
  • Do not cache license or entitlement responses keyed only by path unless you enjoy cross-user authorization bugs.
  • Measure origin egress separately from CDN egress. They answer different cost and reliability questions.

Was this lesson helpful?

Sign in to rate