What Is CDN?
Content Delivery Network
A CDN is a network of servers distributed worldwide that caches and delivers content from locations geographically close to users. CDNs dramatically reduce load times by serving static assets (images, CSS, JS) from edge servers instead of your origin server.
How CDN Works
Without a CDN, a user in Tokyo requesting your site hosted in Virginia experiences ~200ms of network latency per request. With a CDN like Cloudflare or AWS CloudFront, the content is cached at an edge server in Tokyo — latency drops to ~20ms.
CDNs handle more than just static files. Modern CDNs like Cloudflare Workers and Vercel Edge Functions can run serverless code at the edge. They also provide DDoS protection, SSL termination, and image optimization.
Why Developers Use CDN
Every production website should use a CDN. Cloudflare (free tier), AWS CloudFront, Fastly, and Vercel all offer CDN services. For static sites and SPAs, the CDN often replaces traditional hosting entirely. For dynamic sites, it caches static assets and acts as a reverse proxy.
Key Concepts
- Edge Server — A CDN server geographically close to the user that serves cached content
- Cache Invalidation — Clearing outdated content from CDN edges when you deploy new versions
- Origin Server — Your actual web server that the CDN pulls content from when cache misses
- TTL — Time-to-live — how long a CDN caches content before re-fetching from origin
Frequently Asked Questions
Is a CDN the same as web hosting?
No, but they complement each other. Your hosting runs the application; the CDN caches and distributes its output globally. For static sites, the CDN effectively becomes the host.
Do I need a CDN for a small site?
Yes — Cloudflare's free plan gives you a global CDN, DDoS protection, and SSL. There's no reason not to use one, even for small projects.