CDN
Content Delivery Network
A geographically distributed network of servers that caches content close to users to cut latency and reduce load on the origin.
A CDN (Content Delivery Network) places copies of content on servers distributed around the world. When a user requests a file — an image, video, JavaScript bundle — the request goes to the nearest CDN node rather than the distant origin server. Less distance means lower latency and faster page loads.
How a CDN works
A CDN operator maintains Points of Presence (PoPs) in data centers across dozens or hundreds of cities. Each PoP holds a cache of content fetched from origin servers. When a user's browser requests a resource, anycast routing directs the DNS query and connection to the geographically nearest PoP. On a cache hit, the PoP responds directly. On a cache miss, the PoP fetches the file from the origin server, stores a copy, and serves it to the user. Subsequent requests from the same region are served from the cached copy without contacting origin again.
Why distance matters
Data travels through fiber at roughly 200,000 km/s. Every 1,000 km of cable adds approximately 5 ms of one-way delay. A user in London fetching from a server in Los Angeles traverses ~9,000 km of cable, adding 45 ms before any processing. A CDN node in Frankfurt, 15 ms away, serves the same file in a fraction of the time. CDNs solve a latency problem, not a bandwidth problem — even a 1 Gbps connection still waits for the round trip on every uncached request.
What a CDN caches vs what it proxies
CDNs cache static, immutable, or slowly changing content: images, videos, JavaScript and CSS files, fonts, software downloads, and HTML pages that are the same for all users. Cache lifetimes are controlled by the origin via Cache-Control headers — max-age=31536000 tells the CDN to cache for one year; no-store prevents caching entirely. Dynamic content — personalised pages, API responses, shopping cart state, authenticated requests — typically bypasses the cache and is proxied through to origin. Many CDNs offer programmable edge logic (Cloudflare Workers, Fastly Compute) that can generate or transform responses at the edge without touching origin at all.
Major CDN providers
| Provider | PoP locations | Notable strength |
|---|---|---|
| Cloudflare | 300+ | DDoS mitigation, free tier, Workers edge compute |
| Akamai | 4,000+ | Largest edge network, enterprise media delivery |
| Fastly | 90+ | Instant cache purge, VCL programmability |
| Amazon CloudFront | 600+ | Deep AWS integration, Lambda@Edge |
| Google Cloud CDN | Global | GCP integration, anycast via Google's backbone |
CDN and ISP peering
Major CDNs peer directly with ISPs — sometimes placing servers inside ISP data centers. When Cloudflare or Akamai has a server inside your ISP's network, traffic to CDN-hosted content never leaves your ISP's infrastructure at all. This is why CDN-served content often loads faster than content hosted on a dedicated server with a nominally faster connection: fewer network hops, no transit costs, and lower latency regardless of your internet plan's headline speed.
CDN security features
Modern CDNs have evolved beyond caching into security platforms. DDoS mitigation is built in — attack traffic is absorbed across hundreds of PoPs rather than reaching the origin. Web Application Firewalls (WAFs) inspect HTTP requests at the edge and block SQL injection, XSS, and known attack signatures before they reach the application. TLS termination happens at the CDN edge, offloading certificate management and encryption processing from the origin server. Some CDNs provide bot management, rate limiting, and API gateway capabilities at the edge as well.
How to identify CDN-served content
HTTP response headers reveal whether content came from a CDN. Cloudflare adds cf-cache-status: HIT or MISS. Akamai adds X-Check-Cacheable and X-Cache. Amazon CloudFront adds X-Cache: Hit from cloudfront. The Server header often names the CDN. In browser DevTools (Network tab), look at the response headers for any resource — a cache hit from a nearby PoP will typically show a very low Time to First Byte (TTFB), often under 20 ms, regardless of where the origin server is located.
Frequently Asked Questions
How does a CDN reduce latency?
By serving from a nearby node rather than a distant origin. Physical distance directly determines minimum latency — CDNs shrink that distance to the nearest city rather than the nearest continent.
What content does a CDN cache?
Primarily static content: images, videos, JavaScript, CSS, fonts, and downloads. Dynamic personalised content typically bypasses the cache and goes directly to the origin server.
Does a CDN affect speed test results?
Yes. Speed test servers are often CDN-distributed. A result reflects the path to that test server specifically, not to every server on the internet.