Skip to main content
PreparationZone Logo
PrepZone

Content Delivery Network

Push static assets to edge locations so users worldwide get millisecond load times.

Pass checkpoint below

Read these first

How a CDN works

CloudFront edge delivery

nearest PoPMISS onlyCLIENT
Viewer (Tokyo)GET segment.ts
NETWORK
CloudFrontedge PoP · HIT
STORAGE
Amazon S3streamhub-media
Video segments cached at PoPs; S3 origin fetch only on cache miss.

StreamHub production architecture (AWS)

HTTPSstaticmissAPICLIENT
Mobile / WebStreamHub cli…
NETWORK
Route 53GeoDNS routing
NETWORK
CloudFrontCDN + WAF edge
NETWORK
AWS ALBTLS terminati…
NETWORK
API GatewayJWT · rate li…
STORAGE
Amazon S3media origin
COMPUTE
Amazon EKSAPI · auth · …
DATABASE
ElastiCachesessions · ho…
DATABASE
RDS Postgresprimary + rep…
INTEGRATION
Amazon MSKdomain events
ANALYTICS
OpenSearchstream discov…
OPS
CloudWatchmetrics · X-R…
End-to-end path from user to data — reference this when placing any new service.

CDN flow

  1. User requests cdn.streamhub.com/segments/v_9182/720p/004.ts.
  2. DNS resolves to the nearest edge PoP (point of presence).
  3. Cache HIT — edge serves file from local SSD; origin never contacted.
  4. Cache MISS — edge fetches from origin (S3 or origin shield), caches per TTL, serves user.

What to put on a CDN

Asset typeCache strategyStreamHub example
Video segments (.ts, .m4s)Long TTL, immutable URLsHLS/DASH chunks
Thumbnails / postersMedium TTL, purge on updatecreator avatars, video posters
JS / CSS bundlesLong TTL + content hash in filenameapp.v3f2a1.js
API responsesShort TTL or no cacheOnly public, read-heavy endpoints
  • Video segments (.ts, .m4s)

    Cache strategyLong TTL, immutable URLs
    StreamHub exampleHLS/DASH chunks
  • Thumbnails / posters

    Cache strategyMedium TTL, purge on update
    StreamHub examplecreator avatars, video posters
  • JS / CSS bundles

    Cache strategyLong TTL + content hash in filename
    StreamHub exampleapp.v3f2a1.js
  • API responses

    Cache strategyShort TTL or no cache
    StreamHub exampleOnly public, read-heavy endpoints

Never cache personalised or authenticated API responses at the CDN without careful Vary headers and cache-key design.

Cache control headers

Java
GET /static/app.v3f2a1.js HTTP/1.1
Host: cdn.streamhub.com

HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: public, max-age=31536000, immutable
ETag: "3f2a1b9c"
Java
GET /segments/v_9182/720p/004.ts HTTP/1.1

HTTP/1.1 200 OK
Cache-Control: public, max-age=86400
Content-Type: video/mp2t

Immutable tells browsers and CDNs the URL will never change content — safe to cache forever. Versioned filenames (app.v3f2a1.js) enable this pattern.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 4 sections

  • CDN vs origin architecture
  • Cache invalidation
  • Dynamic content at the edge
  • Measuring CDN effectiveness

Test yourself

Answer these before moving on — recall is what makes it stick.