CDN (Content Delivery Network)

Bring reusable content closer to visitors

An origin with several delivery locations

Origin serverAuthoritative public content
Edge AReusable copy for some visitors
Edge BSeparate cache for other visitors

A hit can use an edge copy. A miss fetches from the origin.

Visitors reach an edge location. Reusable content may be served there; a cache miss needs the origin. Each edge may have a different cached copy.

A visitor opens your site from another part of the world. Every image request travelling to one distant server can add waiting time and use that server’s bandwidth. A content delivery network, or CDN, provides distributed locations that can serve suitable content closer to visitors.

The origin is the source server. An edge location can keep reusable copies, fetch missing content from the origin and apply delivery rules. Network routing chooses a suitable edge; it is not a promise that every visitor always reaches the geographically nearest building.

What you’ll learn

  • Follow an edge hit and an origin fetch.
  • Observe different cached versions at separate edge locations.
  • Choose cache rules and a CDN provider from freshness, privacy, cost and delivery needs.

Decide what may be shared

Images, stylesheets and other public files are common caching candidates. A user’s private order history needs a different policy. A shared cache must not reuse one customer’s private response for another customer.

Cache-control headers and provider rules determine reuse. A cache key identifies the copy: path, query parameters or other request context may affect the answer. Excluding a meaningful difference can serve the wrong content; including unnecessary differences can create many misses.

Expiry and revalidation decide when a copy must be refreshed. A CDN does not automatically cache every response or detect every origin update. Configure rules deliberately and inspect actual hit/miss behaviour.

The same file can have different edge copies

Two edges, one changing origin

Origin version1
Edge AEmpty
Edge BEmpty

Both edges start empty. Read from A to fetch version 1 from the origin.

Origin fetches: 0

Inspect each edge’s cached version, change the origin, read from either edge and purge copies. All versions remain visible.

Read the public file from Edge A, then update the origin to version 2. Read again from A and compare it with an initial read from B. In this teaching model, A keeps version 1 until its copy is removed; B fetches the new version.

Purge the selected edge or all edges, then read again. This model makes purge immediate for clarity. Real providers have propagation behaviour, and browser caches may still contain copies. The counters track origin fetches, not production latency or network distance.

Publish updates without surprising visitors

For versioned public assets, a new filename such as site.v2.css gives the new file a distinct identity. A page must reference that new name; visitors can still hold an old page that references the old asset. Keep required older assets available during the transition.

For a stable URL, use an appropriate lifetime, revalidation or purge process. Purging an edge copy does not automatically clear every browser cache. Review how HTML, assets and API responses are updated together.

If the origin fails, an edge can only serve an existing copy when the policy and provider permit it. A cache miss may still fail. Plan origin recovery, monitor cache-hit ratio and errors, and test both warm and cold caches.

Compare real delivery services

Representative official sources checked 6 October 2026. Provider network size is not a universal guarantee of requests/s, bandwidth or user latency. Measure realistic geography, payloads, cache rules and origin misses.

  • Cloudflare provides distributed caching with configurable behaviour. Compare the plan’s features and limits; its default rules are not permission to cache private responses.
  • Amazon CloudFront is a managed delivery service that can fit AWS origins. Review current pricing, origin access and cache policies.
  • Fastly provides CDN delivery and cache-control capabilities. Evaluate configuration, purge behaviour, support and the selected commercial terms.

Paid services may charge for requests, transfer, features or plans. A low origin bill can still come with edge costs. Compare the full cost under a representative hit rate and traffic mix rather than quoting a single universal price.

Choose around the content and its freshness

A public documentation site

Evaluate broad edge caching and versioned assets. Most visitors can share the same content, but update timing and cold-cache behaviour still matter. Compare measured delivery and cost from the audience’s locations.

A signed-in customer dashboard

Cache public assets separately from private responses. Keep account-specific data out of a shared cache unless the key and policy safely isolate it. A faster wrong answer is not a successful optimisation.

Large media downloads

Evaluate transfer costs, range requests, geographic delivery and origin protection. An edge cache does not replace media access permissions or an origin capacity plan. Test the selected provider with the actual file sizes.

Pull content on demand or distribute it ahead of time

Compare when the copy is placed

Pull missVisitor triggers an origin fetch
Push publicationPublisher prepares supported locations
FreshnessNames, lifetimes and purge policy
FailureDefines the permitted fallback
Pull miss: Visitor triggers an origin fetch → Push publication: Publisher prepares supported locations → Freshness: Names, lifetimes and purge policy → Failure: Defines the permitted fallback

In a pull model, an edge fetches content from the origin when it needs a missing or expired copy. The first request can pay the miss cost. In a push or pre-positioning model, a publishing process distributes content ahead of demand under the provider’s supported contract. That adds publication and storage management.

Prewarming selected popular objects can reduce some cold misses, but it is not proof every edge or browser has the new version. Compare origin load, geography, update frequency and transfer charges, and verify which controls the chosen provider actually exposes.

For large downloads, review range-request handling and cache policy. A regional outage or origin failure still needs an explicit fallback rule; serving an existing copy depends on policy and provider support. Neither delivery model grants access to private content.

Check your design decision

Edge A cached version 1. The origin changed to version 2, but A’s valid copy was not refreshed. What can A return?
Choose one answer. You can try again.

Answer and explanation

Version 1, under the stated reuse policy.

An origin update does not automatically refresh every separate edge copy.

Check your design decision

Which response needs special care before shared edge caching?
Choose one answer. You can try again.

Answer and explanation

A signed-in customer’s private order history.

Private data must not be reused across customers; keys and policy need deliberate isolation.

Check the added design rule

In a pull CDN, what commonly happens when an edge lacks a reusable object?
Choose one answer. You can try again.

Answer and explanation

It requests the object from the origin under its configured policy.

The miss can add origin traffic and delay.

A closer copy still needs a correct policy

A CDN can reduce repeated origin work and improve delivery for suitable content. Hits, misses, freshness, privacy and cache keys decide whether those copies are useful.

Compare providers with actual traffic, geography and costs. Plan publishing and origin recovery; edge delivery is part of the system, not a substitute for its correctness.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Rate Limiting in System Design →