← Lessons

quiz vs the machine

Gold1450

System Design

The CDN for Static and Dynamic

Push content close to users with edge caching for static and dynamic responses.

5 min read · core · beat Gold to climb

What a CDN is

A content delivery network is a fleet of edge servers spread worldwide that cache content near users, cutting latency and origin load.

  • Static content like images and scripts caches well because it rarely changes.
    • These are stored with long lived cache rules at the edge.
  • Dynamic content changes per user but can still benefit from short edge caching or routing acceleration.

How a request is served

The nearest edge answers from cache if it can; otherwise it fetches from origin and stores the result.

Static versus dynamic at the edge

  • For static, set long max age and use versioned filenames so updates bust caches cleanly.
  • For dynamic, cache short lived responses or use the CDN only to accelerate the path to origin.
  • Edge compute can personalize responses without a full origin round trip.

Practical notes

  • Use cache keys that include only fields that change the response.
  • Purge or version assets on deploy to avoid stale content.
  • Keep origin shielded so the CDN absorbs traffic spikes.

Key idea

A CDN caches static content aggressively and accelerates dynamic content, moving work to the edge to lower latency and protect the origin.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does static content cache well at a CDN edge?

2. How can a CDN still help with dynamic content?