NETWORKING / A CONCEPT NOTE

CDN

serving content from a server near your user

~75 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

A Content Delivery Network (CDN) caches static assets — images, JS, CSS, videos — at edge locations around the world. When a user in Tokyo requests your site, the CDN serves from a Tokyo edge node instead of fetching from your origin server in Virginia. This cuts latency dramatically and offloads traffic from your origin.

02 / FOLLOW THE MECHANISM

How a cdn serves a cached file

  1. User

    requests https://cdn.example.com/logo.webp from their browser.

  2. DNS

    resolves the CDN hostname to the nearest edge server (e.g., Tokyo).

  3. Edge server

    checks its local cache. If the file is there and not expired, it serves it immediately (cache hit).

  4. Origin fetch

    on a cache miss, the edge fetches from your origin server, caches it, and serves it to the user.

  5. Cache headers

    Cache-Control: max-age=31536000 tells the edge and browser how long to keep the file.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

check cache headers on a CDN asset

curl -sI https://cdn.example.com/file.js

EXAMPLE 02 · REFERENCE

purge entire CloudFront cache

aws cloudfront create-invalidation --distribution-id DIST_ID --paths "/*"

Explore command anatomy in the CLI lab