HTTP CachingCache-ControlETagHeadersPerformance

HTTP Caching & Headers

Master the caching layer that makes the web fast. Understand how Cache-Control, ETag, and conditional requests let browsers skip network round trips entirely — and why getting caching wrong causes stale data bugs that are painful to debug.

28 min read14 sections
01

Overview

HTTP caching lets browsers store copies of server responses and reuse them for future requests — skipping DNS, TCP, TLS, and server processing entirely. A cached response loads in under 1ms. A network request takes 200ms+. Caching is the single biggest performance lever on the web.

Caching behavior is controlled by HTTP headers — primarily Cache-Control. The server tells the browser how long a response is valid, whether it can be stored, and how to check if it's still fresh. Get these headers right and your site loads instantly on repeat visits. Get them wrong and users see stale data or make unnecessary requests.

This topic connects directly to the HTTP lifecycle — caching short-circuits the entire flow. It's also one of the most practical interview topics: interviewers expect you to know the difference between no-cache and no-store, how ETags work, and how to design a caching strategy for different resource types.

Why this matters

The fastest HTTP request is the one that never happens. Proper caching eliminates 80-95% of network requests on repeat visits. For a site with 40 resources, that's 35+ requests that load from disk in <1ms instead of traveling across the internet.

1 / 14