Glossary

What Is Caching? Web Performance Deep Dive

Caching stores computed results or retrieved data temporarily so future requests can be served faster without repeating the expensive work. Effective caching can reduce page load times by 90%, server load by orders of magnitude, and infrastructure costs significantly.

Cache Layers in a Web Stack

Browser cache: assets stored in the user's browser. CDN cache: edge servers cache content close to users. Reverse-proxy cache (Varnish, Nginx): caches full HTTP responses. Application cache (Redis, Memcached): stores database query results or computed values. Database query cache: the database engine caches query plans and results. Each layer solves different bottlenecks.

Cache-Control Headers

Cache-Control: max-age=31536000, immutable — cache for 1 year, content never changes (use with content-hashed filenames). Cache-Control: no-store — never cache (for sensitive data). Cache-Control: no-cache — always revalidate before using cached version. Cache-Control: stale-while-revalidate=60 — serve stale content for up to 60 seconds while fetching fresh data in the background.

Cache Stampede (Thundering Herd)

When a popular cache key expires, many simultaneous requests all miss the cache and hammer the origin simultaneously. Solutions: probabilistic early re-computation (Fetch on Expired Key, PER algorithm), request coalescing (only one request hits origin, others wait), or using a background worker to refresh caches before they expire.