100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is a CDN (Content Delivery Network)?

Learn what a CDN is — edge caching, lower latency, origin offload and DDoS mitigation — with examples and system design interview questions answered.

easyQ4 of 224 in System Design Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

A CDN (Content Delivery Network) is a geographically distributed network of edge servers that cache and serve content from a location close to each user, reducing latency and offloading traffic from the origin server.

Instead of every user fetching assets from one origin server that may be continents away, a CDN caches copies at edge locations around the world and serves each user from the nearest one, cutting round-trip time. It is ideal for static content — images, CSS, JavaScript, video — and uses cache TTLs to decide how long an edge keeps a copy before revalidating with the origin. Beyond speed, CDNs absorb traffic spikes, reduce origin load and bandwidth costs, and help mitigate DDoS attacks by distributing and filtering traffic at the edge.

  • Lower latency by serving from a nearby edge location
  • Offloads traffic and bandwidth from the origin server
  • Absorbs spikes and helps mitigate DDoS attacks

AI Mentor Explanation

A CDN is like stocking official merchandise in local club shops in every city rather than shipping every jersey from one central warehouse abroad. Fans get their kit from the nearby shop instantly instead of waiting on international delivery — that nearness is the whole point. The shops restock from the warehouse periodically (cache TTL). Serving content from the closest edge rather than a distant origin is exactly what a CDN does.

Step-by-Step Explanation

  1. Step 1

    Cache at the edge

    The CDN copies origin content to edge servers around the world.

  2. Step 2

    Route to the nearest edge

    A user’s request is directed to the geographically closest edge location.

  3. Step 3

    Serve or fetch

    A cached asset is served instantly; a miss is fetched from the origin and cached.

  4. Step 4

    Expire with TTL

    Cache TTLs control how long an edge keeps content before revalidating.

What Interviewer Expects

  • Edge servers caching content geographically close to users
  • Latency reduction as the core benefit
  • Best suited to static assets (images, CSS, JS, video)
  • Origin offload and DDoS mitigation awareness

Common Mistakes

  • Thinking a CDN replaces the origin server rather than caching in front of it
  • Assuming CDNs are only for images
  • Ignoring cache invalidation and TTLs for updated assets
  • Overlooking security/DDoS-mitigation benefits

Best Answer (HR Friendly)

A CDN is a network of servers spread around the world that store copies of a site’s content close to users. When someone visits, they get files from a nearby server instead of a distant one, so pages load faster and the main server handles less traffic.

Code Example

Serving static assets via a CDN URL
<!-- Origin serves HTML; the CDN serves heavy static assets -->
<link rel="stylesheet" href="https://cdn.example.com/css/app.css">
<script src="https://cdn.example.com/js/app.js" defer></script>
<img src="https://cdn.example.com/img/hero.jpg" alt="Hero">

<!-- Cache-Control header the origin sends so edges cache for 1 day -->
<!-- Cache-Control: public, max-age=86400 -->

Follow-up Questions

  • What is the difference between an origin server and an edge server?
  • How does a CDN handle cache invalidation when content changes?
  • What types of content are and are not good CDN candidates?
  • How do CDNs help mitigate DDoS attacks?

MCQ Practice

1. The primary benefit of a CDN is?

A CDN serves content from an edge close to the user, cutting round-trip time and latency.

2. CDNs are best suited to serving?

Static, cacheable content benefits most because identical copies can be served from every edge.

3. What controls how long an edge server keeps a cached copy?

The cache TTL (time-to-live) determines how long an edge serves a copy before revalidating with the origin.

Flash Cards

What is a CDN?A network of edge servers caching content close to users to cut latency.

Origin vs edge?Origin is the source of truth; edges are distributed caches near users.

Best CDN content?Static assets — images, CSS, JavaScript and video.

Extra CDN benefits?Origin offload, spike absorption and DDoS mitigation.

1 / 4

Continue Learning