CDN

Caching

Overview

A CDN (Content Delivery Network) is a globally distributed network of edge servers that serves content from close to the user, reducing latency and offloading the origin server.

Beyond caching static assets, it also performs edge functions like TLS termination, compression, routing optimization, and DDoS mitigation.

Details

How it works: when a user hits a CDN domain, DNS/anycast routes them to the nearest edge node, which returns cached content instantly (a cache hit). On a miss, the node fetches from the origin, stores it, and responds. What gets cached and for how long is dictated by the origin's cache headers (`Cache-Control`, `ETag`), so cacheability design drives CDN effectiveness.

Shorter physical distance means lower RTT and thus better TTFB, and the origin only handles miss traffic, improving scalability. Modern CDNs go beyond static files to run image resizing and edge functions (Workers) near the user. However, without cache invalidation (purge) and a versioned-filename strategy, you get the 'stale content keeps showing' problem on updates. Conceptually, a CDN is a large, geographically dispersed shared reverse-proxy cache.

Related types