A CDN (Content Delivery Network) is a network of servers around the world that stores copies of your websiteβs files and serves them from the location closest to each user.
Without a CDN, every user hits your single server β which might be in Virginia. A user in Tokyo waits 200ms+ just for the data to travel there and back. With a CDN, that same user gets the files from a server in Tokyo in 20ms.
How it works
- You upload your site to your origin server (or deploy to Vercel, Netlify, etc.)
- The CDN copies your files to βedgeβ servers worldwide (called PoPs β Points of Presence)
- When a user visits your site, the CDN routes them to the nearest edge server
- The edge server returns the cached files β fast
If the edge server doesnβt have the file yet, it fetches it from your origin server, caches it, and serves it. Next request is instant.
What a CDN caches
- Static files β images, CSS, JavaScript, fonts, videos
- HTML pages β if your site is static (like Astro or Next.js with SSG)
- API responses β some CDNs can cache API responses too
Popular CDNs
| CDN | Notes |
|---|---|
| Cloudflare | Free tier, most popular, also does DNS and security |
| Vercel Edge Network | Built into Vercel deployments |
| AWS CloudFront | Amazonβs CDN, integrates with S3 |
| Fastly | Used by GitHub, Stripe, Reddit |
| Bunny CDN | Cheap, simple, great performance |
CDN vs hosting
Your hosting provider runs your origin server. A CDN sits in front of it:
User β CDN Edge (Tokyo) β [cache hit? return file]
β [cache miss? fetch from origin server in Virginia]
Most modern platforms (Vercel, Netlify, Cloudflare Pages) include a CDN automatically. If youβre self-hosting, you add a CDN like Cloudflare in front of your server.
When you need a CDN
- β Your users are in multiple countries/regions
- β You serve large static files (images, videos)
- β You want faster page loads (better SEO, better UX)
- β You want DDoS protection (CDNs absorb traffic spikes)
- β You only have local users and a fast server nearby