Skip to content
What is a CDN — Simple Explanation with Examples

What is a CDN — Simple Explanation with Examples

DodaTech Updated Jun 20, 2026 5 min read

A CDN (Content Delivery Network) is a distributed network of servers that delivers web content to users based on their geographic location, reducing latency and improving load times.

In this guide, you’ll learn how CDNs work, why they’re essential for modern websites, and how to use them to speed up your own applications. CDNs power everything from streaming video to e-commerce checkout pages.

Why CDNs Exist — The Problem They Solve

The internet is a global network, but physical distance still matters. A user in Tokyo requesting a page from a server in New York experiences noticeable delay (latency):

  • Round-trip time: ~200ms for Tokyo ↔ New York
  • Packet loss: Higher over long distances
  • Bandwidth bottlenecks: A single server can only handle so many concurrent connections

A CDN solves this by placing servers (called edge servers) in multiple geographic locations. When a user requests content, the CDN delivers it from the nearest edge server instead of the origin.

The Traffic Spike Problem

When a website goes viral or experiences a traffic surge, a single origin server can be overwhelmed. CDNs absorb this load by distributing it across hundreds or thousands of edge servers, preventing crashes.

The Analogy — Warehouse vs Local Store

Imagine you own a company that sells widgets. All your inventory is in a single central warehouse. Customers anywhere in the world must order from that one warehouse, paying high shipping costs and waiting weeks for delivery.

Now imagine opening small retail stores in every major city. Customers walk in and get widgets instantly. That’s a CDN.

The central warehouse is your origin server. The local stores are edge servers. When a customer wants a widget, they go to the nearest store. If the store doesn’t have it, it fetches one from the warehouse and keeps it on the shelf for the next customer (caching).

How a CDN Routes Requests

User in London
       │
       ▼
┌──────────────────┐
│  DNS Resolution  │  CDN's DNS returns IP of nearest edge server
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│  London Edge     │  Edge server checks its cache
│  Server          │
└──┬───────────────┘
   │                        ┌──────────────────┐
   ├── Cache HIT ──────────►│  Serve cached     │
   │                        │  content instantly │
   │                        └──────────────────┘
   │
   └── Cache MISS ─────────►┌──────────────────┐
                            │  Fetch from       │
                            │  origin server     │
                            ├──────────────────┤
                            │  Cache for next   │
                            │  request          │
                            │  (set TTL)        │
                            └──────────────────┘

Static vs Dynamic Content

CDNs handle both types, but differently:

TypeDescriptionCacheable?Examples
StaticRarely changesYes (long TTL)Images, CSS, JS, fonts, PDFs
DynamicChanges per user/requestLimited or noAPI responses, user profiles, stock prices

Caching Strategy

# Nginx config — cache static assets for 1 year
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 365d;
    add_header Cache-Control "public, immutable";
}

CDN Benefits

BenefitImpact
Speed50–80% reduction in page load time for global users
ReliabilityIf one edge server fails, traffic routes to another
DDoS protectionCDNs absorb massive traffic spikes (Cloudflare: 26M req/s)
Bandwidth savingsOrigin server handles fewer requests (cache hit rate >90%)
SSL terminationCDNs handle TLS at the edge, offloading origin servers

Popular CDNs

CDNKey FeatureGlobal Servers
CloudflareBuilt-in DDoS + WAF + CDN330+ cities
AkamaiEnterprise-grade, dynamic acceleration4,100+ locations
FastlyInstant cache purge, edge computing (VCL/Compute)100+ PoPs
Amazon CloudFrontTight AWS integration, Origin Shield600+ PoPs
KeyCDNSimple pricing, real-time analytics40+ PoPs

Code Example — Serving via CDN

Without CDN (origin only)

<!-- Direct origin server — slow for global users -->
<script src="https://api.example.com/js/app.js"></script>

With CDN

<!-- CDN-hosted — served from nearest edge -->
<script src="https://cdn.example.com/js/app.js"></script>

<!-- Or use a public CDN for popular libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js"></script>

Custom Domain with CDN (Cloudflare example)

# DNS setup — proxy through Cloudflare
example.com       A     203.0.113.1   (proxied: orange cloud ☁️)
www.example.com   CNAME example.com   (proxied: orange cloud ☁️)

Set Cache-Control headers on origin to control what the CDN caches:

// Express.js — CDN caching headers
app.get('/api/posts', (req, res) => {
  res.set('Cache-Control', 'public, max-age=300, s-maxage=600');
  res.json(posts);
});

s-maxage specifically tells CDNs how long to cache (vs max-age for browsers).

Common Use Cases

1. Media streaming

Netflix serves 15% of global internet traffic through its own CDN (Open Connect). YouTube, Twitch, and Spotify all rely on CDNs to stream video and audio.

2. E-commerce

Amazon, Shopify stores, and Alibaba use CDNs to deliver product images, JavaScript bundles, and checkout pages quickly — directly impacting conversion rates.

3. Software downloads

Microsoft distributes Windows updates. Steam delivers game installs. CDNs handle terabytes of downloads per second.

4. News and media websites

BBC, CNN, and The Guardian serve millions of daily readers from CDN edge servers to handle traffic spikes during breaking news.

5. Global SaaS applications

Slack, Notion, and Figma use CDNs to serve static assets (app bundles, images) quickly to users worldwide while API calls go to origin servers.

FAQ

Is a CDN only for large websites?

No. Even small sites benefit from CDNs — free tiers from Cloudflare, Bunny CDN, and others make it accessible. Faster load times improve SEO and user experience at any scale.

Does a CDN replace web hosting?

No. A CDN sits in front of your web server (origin). The origin still runs your application. The CDN just handles the delivery of cached content.

How does a CDN know which edge server is closest?

Geo-DNS — the CDN’s DNS server looks up the user’s IP address, determines their geographic location, and returns the IP of the nearest edge server.

What is a CDN cache hit ratio?

The percentage of requests served from the edge cache without hitting the origin. A good ratio is 90%+ for static content. Lower for dynamic content.

Are CDNs expensive?

Basic CDN usage is very affordable. Cloudflare offers a generous free plan. Enterprise CDNs (Akamai, Fastly) charge based on bandwidth and feature tiers.

Related Terms

DNS, Caching, Load Balancing, Cloud Computing, HTTPS

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro