What Is a CDN? Content Delivery Networks, Explained
A CDN caches your content on servers around the world so users load it from nearby. How CDNs cut latency, protect origins, and power dynamic apps.
A CDN — Content Delivery Network — is a geographically distributed network of servers that caches copies of your content close to your users. Instead of every visitor fetching your JavaScript bundle or hero image from a data center in Virginia, a user in Tokyo gets it from a nearby edge node. The physics of light-speed networking means less distance literally equals less latency.
CDNs are not optional niceties for large sites — they are standard infrastructure. Even a modest static blog benefits from one, and Core Web Vitals scores are directly affected by whether key assets are served from a nearby edge or a distant origin.
How a CDN works
A CDN consists of edge locations (also called Points of Presence, or PoPs) distributed across cities and regions worldwide. The flow for a cacheable request looks like this:
- A user’s browser makes a request for
https://example.com/logo.png. - DNS routes that request to the nearest edge node (typically using Anycast routing or geo-aware DNS responses).
- Cache hit: If the edge node already has a valid cached copy, it returns the asset directly. The origin server is never involved.
- Cache miss: If the edge has no copy (or its copy has expired), it fetches the asset from your origin server — the actual server or cloud storage you own — caches it locally, then returns it to the user.
Subsequent users in the same region get the cached version. This is called origin offload: the CDN absorbs the majority of traffic so your origin only handles cache misses and requests that can’t be cached (like authenticated API responses).
What a CDN accelerates
Static assets are the classic use case: images, fonts, CSS, JavaScript bundles, PDFs — anything that doesn’t change per-user. A CDN is essentially free performance for this category.
Increasingly, CDNs handle more:
- Dynamic content — CDNs can cache API responses with short TTLs, or use stale-while-revalidate strategies so users never wait.
- Edge compute — providers like Cloudflare Workers, Fastly Compute, and AWS Lambda@Edge let you run code at the PoP, enabling personalization, A/B testing, and authentication without a round-trip to the origin.
- Video streaming — large media files are segmented and delivered from the edge to avoid buffering.
The benefits
Lower latency. The dominant factor in page load time for cached assets is the round-trip time (RTT) to the server. Serving from 10 ms away instead of 200 ms away is immediately measurable in user experience.
Origin offload and cost reduction. If 95% of your traffic is cache hits, your origin handles 5% of the load. This translates directly to smaller (cheaper) origin infrastructure.
DDoS protection. A CDN’s distributed capacity can absorb volumetric attacks (floods of traffic designed to overwhelm your origin) that would take down an unprotected server. Many CDNs include WAF (Web Application Firewall) rules as part of the package.
Higher availability. If your origin goes briefly offline, the CDN can continue serving cached content, shielding users from downtime.
Cache-Control and invalidation
CDNs respect standard HTTP Cache-Control headers you set on your origin responses:
Cache-Control: public, max-age=31536000, immutable
This tells the CDN (and the browser) it can cache the response for one year without checking back. This is appropriate for content-hashed assets (files whose filenames include a hash of their contents, so the URL changes when the file changes).
For content that updates on a known schedule or on deploy, use a shorter max-age or s-maxage (which applies only to shared caches like CDNs, not the browser):
Cache-Control: public, s-maxage=3600, stale-while-revalidate=86400
When you need to invalidate a cached file immediately — say, after a hot-fix deploy — most CDNs expose a purge API. Purging is just cache invalidation at the edge — the same hard problem every caching layer shares. Cloudflare, for example, lets you purge by URL, tag, or entire cache zone. Build tooling (like the deploy workflow in deploying Astro to Cloudflare Pages) can automate this as part of CI/CD.
Putting it together
A CDN sits between your users and your origin, absorbing traffic, reducing latency, and protecting your infrastructure. For static sites and SPAs it is essentially free performance — set sensible Cache-Control headers, push your assets to the edge, and users worldwide get fast load times regardless of where your origin server lives. As CDNs have grown to support compute at the edge, they are also becoming a platform for building fast, globally distributed applications — not just a caching layer. Understanding how CDNs work is foundational to understanding modern web performance and architecture.
Tagged
Keep reading
The Lycoris Team · · 7 min read What Is a Load Balancer? How It Works, Explained
A load balancer distributes traffic across servers to prevent overload and downtime. Layer 4 vs Layer 7, routing algorithms, health checks, and TLS.
Chisato · · 4 min read What Is a NAT Gateway?
A NAT gateway lets private-subnet resources reach the internet outbound while staying unreachable from it, translating private IPs to a public one.
Takina · · 4 min read HTTP Range Requests and Partial Content, Explained
HTTP range requests let a client ask for just part of a resource, enabling video seeking, resumable downloads, and partial file fetches over HTTP.