πŸ“ Tutorials
Β· 2 min read

What is a CDN? A Simple Explanation for Developers


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

  1. You upload your site to your origin server (or deploy to Vercel, Netlify, etc.)
  2. The CDN copies your files to β€œedge” servers worldwide (called PoPs β€” Points of Presence)
  3. When a user visits your site, the CDN routes them to the nearest edge server
  4. 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
CDNNotes
CloudflareFree tier, most popular, also does DNS and security
Vercel Edge NetworkBuilt into Vercel deployments
AWS CloudFrontAmazon’s CDN, integrates with S3
FastlyUsed by GitHub, Stripe, Reddit
Bunny CDNCheap, 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