CDN
A network of edge caches that serves content from a location close to users, cutting latency and offloading origin. It caches static and cacheable dynamic content by URL and headers. The origin only sees cache misses.
- Static assets, media, and any cacheable HTML/API responses.
- Global audiences and DDoS/traffic-spike absorption.
- Highly personalized per-user content with no shared cacheability.
- Low-traffic single-region apps where origin is already close.
Definition
A Content Delivery Network is geographically distributed reverse proxies that cache responses keyed by URL + Vary headers and serve them near the user. Misses fetch from origin; hits return instantly. CDNs also terminate TLS, do compression, and shield origin.
Why it exists
Speed of light makes a single origin slow for global users, and one origin can't absorb traffic spikes or absorb DDoS. Edge caching puts bytes close to users and absorbs load.
How it works
Request hits the nearest edge POP via DNS/anycast. If cached (and fresh per Cache-Control/ TTL), serve. Else fetch origin, store by cache key, return. Stale-while-revalidate and surrogate keys let you purge selectively. CDN sits in front of the origin as a reverse proxy.
Scaling limits
Cache hit ratio determines origin load and latency. Personalized or uncacheable content defeats the CDN. Purge propagation and cache key correctness (e.g. normalizing Vary) are ongoing ops concerns.
Cost shape
You pay for egress (often cheaper than origin egress), requests, and features (image optimization, WAF). Blow-ups: serving huge uncacheable files through the CDN, or cache-key explosion from query strings causing low hit ratio.
Alternatives
- Origin + reverse proxy cache — Simpler, no edge POPs, but no geographic latency win.
- Edge functions — Run logic at the edge for personalization, more complex than caching.
Failure modes
- Caching personalized responses (leaks across users).
- Origin shield bypassed during a purge causing a thundering herd.
- Stale content served past intent due to long TTLs.