Loading pattern...

What is CDN (Content Delivery Network)?

A CDN (Content Delivery Network) caches your content (images, CSS, JS, videos) on servers distributed globally. When a user in Tokyo visits your site, they get content from a Tokyo server, not your US server—much faster. Like having warehouses in every city instead of shipping everything from one location. CDNs also absorb traffic spikes and DDoS attacks. Common providers: Cloudflare, AWS CloudFront, Fastly. Essential for global apps.

When Should You Use This?

Use a CDN when you have users globally (latency matters), serve static assets (images, videos, CSS, JS), need to handle traffic spikes, or want DDoS protection. Start with free tiers (Cloudflare, Vercel auto-CDN). Skip if all users are in one region or you only have dynamic content. Most modern hosting (Vercel, Netlify) includes CDN automatically.

Common Mistakes to Avoid

  • Not using CDN at all—even US-only apps benefit from edge caching
  • Only CDN for images—cache CSS, JS, fonts too
  • No cache headers—CDN doesn't know what to cache or for how long
  • Ignoring invalidation—old cached content stays after updates, purge cache on deploy
  • Not monitoring hit rate—low hit rate means misconfigured caching

Real-World Examples

  • Netflix—CDN caches videos at ISP level, serves billions of streams
  • Shopify—Product images served from CDN, instant loads globally
  • News sites—Articles cached at edge, handle traffic spikes for breaking news
  • SaaS apps—Static assets (JS bundles) on CDN, 10x faster page loads

Category

System Design Patterns

Tags

cdnperformancecachingglobal-deliverycloudflare

Permalink