HTTP Caching Fundamentals: The Foundation of CDN Performance

· James Thornton · 4 min read

Why HTTP Caching Matters

HTTP caching is the single most impactful performance optimization on the web. A cached response eliminates network round-trips, reduces server load, and delivers content in milliseconds instead of seconds. Every CDN is fundamentally an HTTP cache — understanding how HTTP caching works is prerequisite to using a CDN effectively. For foundational context, read What Is a CDN? The Complete Beginner's Guide — FlyFish NWA.

Cache-Control: The Primary Header

The Cache-Control response header is the primary mechanism for controlling caching behavior. It contains directives that apply to both browser caches and CDN caches.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages
CDN Cache Hierarchy — Multi-tier caching architecture from edge to originCDN Cache Hierarchy — Multi-tier caching architecture from edge to origin CDN Cache Hierarchy — Multi-Tier Architecture L1 Edge Cache Hit Rate: 95% Latency: < 5ms miss L2 Regional Cache Hit Rate: 85% Latency: 10–30ms miss Origin Shield Hit Rate: 70% Latency: 50–80ms miss Origin Server Hit Rate: — Latency: 100–300ms
Figure 1: CDN Cache Hierarchy — Multi-tier caching architecture from edge to origin

Key Directives

See Cache-Control Deep Dive for every directive with examples.

Conditional Requests

When a cached response expires, the cache doesn't have to fetch the full response again. It can send a conditional request to check if the content has changed:

ETag + If-None-Match

# Original response:
HTTP/1.1 200 OK
ETag: "abc123"
Cache-Control: max-age=300

# After 300s, cache revalidates:
GET /style.css HTTP/1.1
If-None-Match: "abc123"

# If unchanged:
HTTP/1.1 304 Not Modified  (no body, saving bandwidth)

# If changed:
HTTP/1.1 200 OK
ETag: "def456"
(full response body)

Last-Modified + If-Modified-Since

# Original response:
HTTP/1.1 200 OK
Last-Modified: Mon, 01 Jun 2026 10:00:00 GMT

# Revalidation:
GET /style.css HTTP/1.1
If-Modified-Since: Mon, 01 Jun 2026 10:00:00 GMT

The Vary Header

The Vary header tells caches that the response varies based on certain request headers. The cache must store separate copies for different values of those headers:

Cache Decision Flow — How the CDN determines cache hit vs missCache Decision Flow — How the CDN determines cache hit vs miss CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: Cache Decision Flow — How the CDN determines cache hit vs miss
Vary: Accept-Encoding
# Cache stores separate copies for gzip, br, and identity encodings

Vary: Accept-Language
# Cache stores separate copies per language — use cautiously

Overusing Vary fragments your cache and reduces hit rates. See cache key design.

Cache Layers

An HTTP response passes through multiple cache layers:

  1. Browser cache — Closest to user, governed by max-age. See browser vs CDN cache.
  2. CDN edge cache — Shared cache at the nearest PoP, governed by s-maxage
  3. CDN shield cache — Regional aggregation layer. See cache hierarchy.
  4. Origin server — Source of truth when all caches miss

Cache Freshness Model

A cached response has three states:

Common Caching Mistakes

These caching fundamentals apply universally across CDN providers and deployment scenarios. For a broader introduction to content delivery networks and their practical benefits beyond caching, see this overview of CDN technology and its six key advantages, which covers the business case for CDN adoption alongside the technical considerations explored throughout this guide.

External References

References & Standards: Cloudflare documentation · W3C Web Performance