What is a CDN (Content Delivery Network)?

Last updated: July 2026

A CDN is a network of distributed servers that caches content close to users, so pages and files load fast everywhere. Physics is the problem it solves: a request from São Paulo to a server in Frankfurt pays the round trip in latency, every time. A CDN answers from São Paulo instead — and one clarification saves endless confusion: it complements your hosting, it never replaces it.

Key takeaways

QuestionAnswer
What it isDistributed edge servers holding cached copies of your content
Problem it solvesDistance — latency scales with the round trip to your origin
The mechanismRoute to nearest edge → cache hit serves instantly; miss fetches from origin once
The knobsCache-Control headers, TTL, purge or versioned filenames
What it isn’tA web host, or edge computing — delivery, not storage or logic

The knobs that make it work

The whole caching contract fits in one HTTP header — and it’s the single most under-explained piece of every CDN explainer:

# The origin's instruction to every cache between it and the user:
Cache-Control: public, max-age=300, s-maxage=86400, stale-while-revalidate=3600

  public                  → any cache may store this
  max-age=300             → browsers: fresh for 5 minutes
  s-maxage=86400          → CDN edges: fresh for 24 hours
  stale-while-revalidate  → serve stale instantly, refresh in background

# The other strategy: never expire, never purge — version the filename
/_assets/app.3f9c1b.css   → cache "forever"; a new build means a new URL

Where files come from in an app matters too — on a managed backend, an upload returns a delivery-ready URL with the caching story already sane:

// JavaScript / Node.js — Back4app JS SDK
// Upload once; the returned URL serves from edge cache worldwide
const file = new Parse.File('hero.webp', { base64: imageData });
await file.save();
console.log(file.url()); // CDN-backed, cache-friendly URL

Anatomy of a request

How a CDN serves a requestA user is routed to the nearest point of presence; a cache hit is served from the edge immediately, while a miss fetches from the origin server, caches the response per its TTL, and then serves it locally.

cache hit

cache miss

response + TTL

User

Routing
(nearest PoP)

Edge server

Answered in ms

Origin server

A user is routed to the nearest point of presence; a cache hit is served from the edge immediately, while a miss fetches from the origin server, caches the response per its TTL, and then serves it locally.

The vocabulary in one pass: the origin is your actual server — the source of truth. A PoP (point of presence) is a CDN data-center location; edge servers are the caching machines inside it. The cache-hit ratio — the share of requests answered without touching the origin — is the metric the whole exercise optimizes, and the levers are the headers above. What improves for users is TTFB (time to first byte) and, when full pages are edge-cached, the loading metrics that follow from it.

CDN vs. web hosting vs. edge computing

DimensionWeb hosting (origin)CDNEdge computing
RoleStores the authoritative contentDistributes cached copiesRuns logic near users
Answers”Where does my site live?""Why is it fast in Tokyo?""Can I compute in Tokyo?”
StatePermanentTemporary, TTL-boundUsually stateless
Without itNo siteSlow site, exposed originRound trips for every decision
Typical contentEverything, onceStatic assets, media, full cached pagesPersonalization, auth checks, rewrites

The MDN definition adds the caveat vendor pages skip: third-party CDN scripts are a supply-chain dependency (integrity attributes exist for a reason), and an extra DNS lookup to a CDN can even cost time on a first visit — leverage, not magic.

Common use cases

  • Static assets at scale. CSS, JavaScript, fonts, images — fingerprinted filenames plus long TTLs turn repeat visits into pure edge traffic.
  • Media and downloads. Video segments and large files, where origin bandwidth would be the bill and the bottleneck.
  • Global audiences. The same page served under 100 ms on four continents without running servers on four continents.
  • Traffic spikes and launches. The edge absorbs the surge; the origin sees a fraction of it.
  • Security posture. Origin hidden behind a reverse proxy, TLS terminated at the edge, volumetric attacks dissipated across the network.

Do you need a CDN? A decision matrix

A CDN pays when…Skip (or defer) it when…
Users are far from your originYour audience is local to your server’s region
Assets and media dominate your trafficThe app is small, dynamic, and API-bound
Traffic spikes are part of the businessTraffic is too low for caches to stay warm
Origin bandwidth is a real costThe extra moving part outweighs the ms saved
You want DDoS absorption in front of originYou’d be caching personalized responses (you can’t)

The honest row nobody prints: on a low-traffic site, cached copies expire between visitors, every request is a miss, and the CDN adds a hop for nothing. Distance and volume are the inputs; without either, fix something else first.

Limitations and trade-offs

  • Stale content is the default failure. Long TTLs mean yesterday’s file served confidently today; the cure is purging (slow, per-CDN) or versioned filenames (better).
  • Cache invalidation is genuinely hard. It’s one of the two famous hard problems for a reason — design URLs so you rarely need it.
  • Dynamic content resists caching. Per-user responses can’t be shared; acceleration and edge logic help, but the origin still does the work.
  • A dependency in the critical path. CDN outages are internet-weather events; when the edge is down, “your” site is down.
  • Debugging gets a layer. Which cache served this? With which headers? Cache-status headers and per-edge behavior become part of your observability surface.

CDNs and Back4app

Back4app is an open-source Backend-as-a-Service (BaaS) platform that combines a managed database, auto-generated REST and GraphQL APIs, authentication, file storage, and Cloud Code serverless functions. The CDN story is built into the file layer: upload through any SDK (the tabs above) and the returned URL is delivery-ready — stable, cacheable, and independent of your API’s dynamic traffic, which keeps the cacheable and uncacheable halves of your app cleanly separated. Web frontends hosted on Back4app Containers sit naturally behind any CDN, with the classic pattern — long-lived fingerprinted assets, short-lived HTML — configured in one header.

Frequently asked questions

What is a CDN in simple terms?

A geographically distributed network of servers that keeps cached copies of your content close to your users. Instead of every request traveling to your origin server — possibly across an ocean — most are answered by a nearby edge server in milliseconds. The majority of major-site web traffic is served this way.

How does a CDN work?

Routing plus caching. A user's request is steered to the nearest point of presence; if that edge server holds a fresh cached copy (a cache hit), it answers immediately. If not (a miss), the edge fetches from your origin, stores a copy for the time-to-live you configured, and serves everyone nearby from cache until it expires.

Is a CDN the same as web hosting?

No — a CDN complements hosting, never replaces it. Your host (origin) stores the authoritative content; the CDN holds temporary copies at the edge. If the origin disappears, the CDN eventually has nothing to serve. The division of labor: origin is the source of truth, CDN is the distribution layer.

What are a cache hit, a cache miss, and TTL?

A hit means the edge served its cached copy — fast, and the origin never noticed. A miss means the edge had no fresh copy and fetched from the origin — slower, once, for the first nearby visitor. TTL (time to live) is how long a cached copy counts as fresh, set via Cache-Control headers. Cache design is mostly the art of maximizing hits without serving stale content.

Can a CDN serve dynamic content?

Not from cache in the classic sense — a personalized API response differs per user. But CDNs still accelerate dynamic traffic through optimized routes, persistent connections, and TLS terminated near the user; and modern platforms run logic at the edge itself. The practical split: cache static assets aggressively, accelerate dynamic responses, and compute at the edge where it pays.

How does a CDN protect against DDoS attacks?

By being enormous and in the way. As a reverse proxy, the CDN hides your origin's address, and its distributed capacity absorbs volumetric attacks across many points of presence — traffic that would flatten one server dissipates across a global network, with filtering applied at the edge before anything reaches you.

When do you NOT need a CDN?

When your audience is local to your server's region, an extra hop through a distant edge can even add latency; when traffic is so low that caches expire between visitors (perpetual misses do nothing); and when a small dynamic app simply is not delivery-bound. A CDN is leverage on distance and volume — without either, it is configuration without benefit.

What is the difference between a CDN and edge computing?

A CDN moves content closer to users; edge computing moves computation closer. Delivery versus decisions: a CDN answers "serve this file fast everywhere," edge functions answer "run this logic near the user." The two converge in practice — modern CDN platforms execute code at their points of presence — but the mental model holds.

Related terms

Compare with

Further reading

Ready to build your backend?

Start your project on Back4app in minutes — database, auth, APIs, and Cloud Code included. No credit card required.

Written and reviewed by Back4app Engineering, Back4app Engineering · Published 2026-07-24