Quick Start Guide
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 work fast tomorrow. You have ten minutes to get up to speed.
This lesson gives you the key CDN facts in 10 minutes. Bookmark it as your quick reference.
What a CDN Actually Does
A CDN caches your content on servers around the world. The full name is Content Delivery Network. When a user asks for something, they get it from a nearby server. Not your origin. The edge serves most of the traffic. The origin only sees the misses.
Result: faster pages and less origin load. Uptime improves as well.
The key insight: CDNs are just HTTP caches. If you understand HTTP caching headers, you understand CDNs.
The Headers That Matter
Most CDN setup comes down to these headers. Each one shapes what the CDN does:
Cache-Control
Cache-Control is the HTTP header field, defined in RFC 9111, that carries caching directives to browsers, proxies and CDNs: whether a response may be stored, by which caches, how long it stays fresh, and what a cache must do once it goes stale.
View full definition| Header | What It Does | Example |
|---|---|---|
| Cache-Control. | Tells the 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) |
Cache-Control Quick Reference
# 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
When to Cache vs. Not Cache
| Content Type | Cache? | Typical TTL |
|---|---|---|
| Static assets (JS, CSS, images). | Yes. | 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 |
Debugging: Why Isn't This Caching?
When content isn't caching, check these in order. Start at the top and work down. One of these is usually the cause:
# 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)
# - Cache-status header (X-Cache, cf-cache-status; varies by CDN)
# - Vary header (could be causing cache fragmentation)
Quick Wins
Things you can do today to improve CDN performance. These wins are quick to ship. Test each change after you make it:
- Add Cache-Control to static assets — If your JS/CSS/images don't have Cache-Control headers, add them. Pair long TTLs with versioned file names.
- Enable compression. Make sure Gzip or Brotli is on. Look for Content-Encoding: gzip.
- Use Vary: Accept-Encoding. Serving compressed content? Add it so CDNs cache both versions right.
- Check your cache hit ratio. Most CDN dashboards show it. Treat 80%+ for static content as a rough target. The right number depends on your content.
- Remove cookies from static asset domains. Keep cookies off asset domains. Serve assets from a cookie-free domain.
Common Mistakes
Avoid these common CDN pitfalls. These mistakes all cost speed or safety:
- Caching HTML with user data. That serves one user's page to another. Use private or no-store for personal content.
- Long TTLs without versioning. Cache for 1 year and you can't change the file. So no updates.
- Forgetting Vary headers. Mobile content ends up on desktop screens. You did not Vary on User-Agent.
- Over-purging. Wiping your cache on every deploy. Use versioned URLs instead.
- Ignoring the origin. A slow origin holds the CDN back. Fix origin speed first.
Next Steps
Now that you have the essentials, you can:
- Go deeper. Module 1 has the full CDN basics.
- Jump to headers. Module 3 covers them all in detail.
- Get hands-on. Module 8 has Nginx and Varnish labs.
- Bookmark this page — Return here when you need a quick reference
Pick the path that fits your goal.
Which directive stops CDNs from caching a response but lets the browser store it?
private limits caching to the browser.
- CDNs are shared caches, so they must not store it.
- no-store stops all caches, even the browser.
- no-cache allows caching, with a check first.
Enjoying this preview?
Unlock all lessons, hands-on exercises, and earn your CDN certification.
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.
No credit card required · Free forever tier available