Skip to main content

CDN (Content Delivery Network)

CDN = distributed servers for faster content delivery


What is a CDN?

"Geographically distributed servers"

A CDN is a network of distributed servers that deliver content based on user location.

"A CDN is a network of geographically distributed servers that cache and deliver content from locations closest to users, reducing latency."


How CDN Works

Origin → Edge servers → Users

  1. Content stored on origin server
  2. CDN caches content on edge servers worldwide
  3. Users get content from nearest edge server
  4. Reduces distance and latency

"CDNs cache content on edge servers close to users, serving from the nearest location instead of the origin server."


Benefits

Speed · Reliability · Bandwidth

  • Faster delivery: Reduced latency
  • Higher availability: Multiple servers
  • Bandwidth savings: Offloads origin server
  • Better performance: Global distribution

"CDNs improve speed through reduced latency, increase reliability with multiple servers, and reduce bandwidth costs."


What Gets Cached

Static assets primarily

  • Images
  • CSS files
  • JavaScript files
  • Fonts
  • Videos
  • HTML (sometimes)

"CDNs primarily cache static assets like images, CSS, JavaScript, and fonts, though some also cache HTML."


CDN Providers

CloudFlare · AWS CloudFront · Akamai

Popular CDNs:

  • CloudFlare: Free tier, DDoS protection
  • AWS CloudFront: Integrated with AWS
  • Akamai: Enterprise-grade
  • Fastly: Real-time purging

"Popular CDN providers include CloudFlare, AWS CloudFront, Akamai, and Fastly, each with different features and pricing."


Cache Invalidation

Purge when content updates

  • TTL (Time To Live): Automatic expiration
  • Manual purge: Force cache clear
  • Versioning: Change URLs (query params, filenames)

"Cache invalidation uses TTL for automatic expiration, manual purging for immediate updates, or URL versioning."


CDN vs Origin Server

CDN = cache, Origin = source

AspectCDNOrigin Server
LocationDistributedSingle location
ContentCachedOriginal
SpeedFast (near users)Slower (far users)
CostPay per usageFixed hosting

"CDNs cache content on distributed servers, while origin servers host the original content."


When to Use CDN

Global audience + static assets

Use when:

  • Global user base
  • Static assets (images, CSS, JS)
  • High traffic
  • Need performance

"Use CDNs for global applications with static assets, high traffic, or performance requirements."


9️⃣ Best Practices

✅ Cache static assets ✅ Use appropriate TTL ✅ Enable compression ✅ Use HTTPS ✅ Monitor cache hit rates ✅ Version assets for cache busting


"A CDN is a network of distributed servers that cache content close to users, reducing latency and improving performance. CDNs cache static assets like images, CSS, and JavaScript on edge servers worldwide. They provide faster delivery, higher availability, and bandwidth savings. Cache invalidation uses TTL, manual purging, or URL versioning."


🧠 Ultra-Short Cheat Sheet

Distributed servers
Cache static assets
Reduced latency
Global distribution
Cache invalidation (TTL/purge/versioning)
Edge servers