Course contentsShow
← System Design
Lesson 121 of 1,9194. Caching StrategiesFree lesson

Browser Caching and HTTP Headers

How browsers cache resources using Cache-Control, ETag, and Expires headers to reduce network requests.

Browser Caching and HTTP Headers

What you'll learn: How browsers use HTTP headers to decide when to store and reuse resources, dramatically reducing network requests.

The Core Idea

Browser caching is the first line of defense in caching hierarchies. When you visit a website, your browser can store images, CSS, JavaScript, and other files locally on your device. On subsequent visits, instead of downloading these files again, the browser checks if it can safely reuse what it already has—guided entirely by HTTP headers sent by the server.

Think of it like checking the expiration date on milk in your fridge. You don't need to go to the store every time you want milk; you check the date first, and only shop if it's expired.

Key HTTP Headers

Cache-Control is the modern workhorse. The server tells the browser how long to keep something:

  • Cache-Control: max-age=3600 means "this resource is fresh for 1 hour"
  • Cache-Control: no-cache means "you can store this, but always check with me before using it"
  • Cache-Control: no-store means "don't cache this at all"

Expires is the older header specifying an absolute date/time when the resource becomes stale (mostly replaced by Cache-Control).

ETag (entity tag) is a unique identifier for a resource version. When the browser checks back with the server, it sends the ETag. The server responds "304 Not Modified" if nothing changed, so the browser uses its cached copy—no download needed.

Real Impact

A typical website loads 50-100 resources. Without browser caching, every page reload downloads everything again. With proper headers, returning visitors might download zero files, making pages feel instant.

Key Takeaway: Browser caching uses Cache-Control, ETag, and Expires headers to let browsers store and intelligently reuse resources, eliminating unnecessary network requests and dramatically improving perceived performance.