Module 0 · Lesson 4 Preview Beginner

Quick Start Guide

10 min read

Need CDN Knowledge Fast?

You've been asked to fix a caching issue. Or evaluate a CDN. Or explain why the site is slow. And you need to be productive tomorrow.

This lesson gives you the essential CDN knowledge to be dangerous in 10 minutes. Bookmark it as your quick reference.

What a CDN Actually Does

A CDN (Content Delivery Network) caches your content on servers around the world. When a user requests something, they get it from a nearby server instead of your origin.

Result: Faster load times, reduced origin load, better reliability.

The key insight: CDNs are just HTTP caches. If you understand HTTP caching headers, you understand CDNs.

The Headers That Matter

90% of CDN configuration comes down to these headers:

Header What It Does Example
Cache-Control Tells CDN how long to cache Cache-Control: public, max-age=3600
ETag Version identifier for revalidation ETag: "abc123"
Vary Cache different versions by header Vary: Accept-Encoding
Age How long content has been cached Age: 120 (seconds)
Essential Caching Headers

Cache-Control Quick Reference

TEXT
# Cache publicly for 1 hour
Cache-Control: public, max-age=3600

# Cache privately (browser only) for 10 minutes
Cache-Control: private, max-age=600

# Don't cache at all
Cache-Control: no-store

# Cache but always revalidate
Cache-Control: no-cache

# Cache for 1 year (static assets with hash in filename)
Cache-Control: public, max-age=31536000, immutable
Common Cache-Control patterns

When to Cache vs. Not Cache

Content Type Cache? Typical TTL
Static assets (JS, CSS, images) Yes - aggressively 1 year (with versioned URLs)
HTML pages Depends Short TTL or no-cache
API responses (public) Often yes Seconds to minutes
API responses (personalized) No no-store
Authenticated content Usually no private or no-store
Real-time data No no-store
Caching Decision Guide

Debugging: Why Isn't This Caching?

When content isn't caching, check these in order:

BASH
# Check response headers
curl -I https://example.com/asset.js

# Look for:
# - Cache-Control header (is it present? what value?)
# - Age header (if present, it's cached)
# - X-Cache header (HIT or MISS)
# - Vary header (could be causing cache fragmentation)
Quick debugging with curl

Quick Wins

Things you can do today to improve CDN performance:

  1. Add Cache-Control to static assets — If your JS/CSS/images don't have Cache-Control headers, add them. Use long TTLs with versioned filenames.
  2. Enable compression — Make sure Gzip or Brotli is enabled. Check for Content-Encoding: gzip in responses.
  3. Use Vary: Accept-Encoding — If you serve compressed content, add this header so CDNs cache both versions correctly.
  4. Check your cache hit ratio — Most CDN dashboards show this. If it's below 80% for static content, something's wrong.
  5. Remove cookies from static asset domains — Serve assets from a cookieless domain or path.

Common Mistakes

Avoid these common CDN pitfalls:

  • Caching HTML with user data — Accidentally serving one user's page to another. Always use private or no-store for personalized content.
  • Long TTLs without versioning — If you cache for 1 year but can't change the filename, you can't update the content.
  • Forgetting Vary headers — Serving mobile content to desktop users (or vice versa) because you didn't Vary on User-Agent.
  • Over-purging — Purging your entire cache on every deploy instead of using versioned URLs.
  • Ignoring the origin — CDN can't help if your origin is slow. Fix origin performance first.

Next Steps

Now that you have the essentials, you can:

  • Go deeper — Continue to Module 1 for comprehensive CDN fundamentals
  • Jump to headers — Module 3 covers all caching headers in detail
  • Get hands-on — Module 6 has labs where you configure Nginx and Varnish
  • Bookmark this page — Return here when you need a quick reference
Quick Check

Which Cache-Control directive tells CDNs NOT to cache a response (only the browser)?

Correct! Not quite.
Explanation

private means the response can be cached by the browser but NOT by shared caches like CDNs. no-store prevents all caching. no-cache allows caching but requires revalidation. public explicitly allows CDN caching.

Enjoying this preview?

Unlock all lessons, hands-on exercises, and earn your CDN certification.

Get Full Access

Ready to Master CDN?

You've just scratched the surface. Create a free account to access the full course, hands-on exercises, and earn your CDN Certified credential.

Free intro module Track progress Certificate

No credit card required · Free forever tier available