Why it matters
Every user-facing service benefits from a CDN. Without one, users far from the origin experience slow loads. With one, the same origin serves users worldwide at near-local latency.
The architecture
Edge nodes: PoPs (points of presence) distributed globally. When a user requests content, DNS routes them to the nearest PoP. If the PoP has cached content, it serves immediately. If not, it fetches from origin and caches.
Cache keys: URL, headers, sometimes cookies. Vary header controls which variants get separate cache entries.
How it works end to end
Cache-control headers: max-age, s-maxage, stale-while-revalidate, no-cache. These control CDN behavior per response.
Cache invalidation: URL-based purge (invalidate specific URL), tag-based purge (invalidate all URLs with a tag), full purge (rare, expensive).
Edge compute: run JS/Wasm at edge for A/B testing, authentication, personalization, or lightweight APIs. Latency near-zero from user.