Course contentsShow
← Cloud and Infrastructure
Lesson 587 of 2,98911. CDN and Edge ComputingFree lesson

TTL and Cache Control Headers

Time-to-live settings, cache-control headers, and how they determine content freshness.

TTL and Cache Control Headers

What you'll learn: How to control how long CDN edge servers cache your content before checking for updates.


When a CDN edge server caches a file from your origin server, it needs to know one critical thing: How long is this content valid? That's where TTL (Time-to-Live) and cache-control headers come in—they're instructions that tell the CDN (and browsers) how long to store content before fetching a fresh copy.

What is TTL?

TTL is a duration—usually measured in seconds—that determines content freshness. Think of it like an expiration date on milk: after that time passes, the edge server should go back to the origin and ask, "Is there a newer version?"

For example:

  • A logo image might have a TTL of 86400 seconds (24 hours)
  • Breaking news content might have 60 seconds
  • Rarely-changing CSS files might have 2592000 seconds (30 days)

Cache-Control Headers

The Cache-Control HTTP header is how your origin server communicates TTL and caching rules:

Cache-Control: max-age=3600

This tells the CDN: "Cache this for 3600 seconds (1 hour)."

Other common directives include:

  • no-cache — Always revalidate with origin before using cached content
  • no-store — Don't cache at all (for sensitive data)
  • public — Any cache can store this (CDNs, browsers)
  • private — Only user's browser can cache (not CDNs)

Why This Matters

Longer TTLs mean:

  • Fewer origin requests → Lower server load, faster responses
  • Higher cache hit ratios (as we learned in lesson 585)

Shorter TTLs mean:

  • Fresher content → Users see updates faster
  • More origin traffic → Slightly higher load

Key Takeaway: TTL and Cache-Control headers are the traffic rules that determine how long CDNs store your content—balancing freshness with performance and cost.