breakitdown

304 Not Modified

Answer

304 Not Modified is the server's reply to a conditional request: the client's cached copy has not changed, so the server sends no body and the client uses what it already has. It is a success, not an error.

304
Not Modified RFC 9110 §15.4.5

The client's cached copy is still current, so the server sends no body.

The answer to a conditional request carrying If-None-Match (an ETag) or If-Modified-Since. The client reuses its stored body and updates the stored headers from the 304. It is not an error, and it is not a redirect despite being in the 3xx range.

Explained

When a cached response goes stale, the browser revalidates instead of downloading again. It sends If-None-Match with the stored ETag, or If-Modified-Since with the stored Last-Modified date. If nothing changed, the server answers 304 with headers only; otherwise it sends a fresh 200.

The 304 should repeat headers that affect caching, such as ETag, Cache-Control and Expires, so the client can update its stored copy's freshness.

A 304 still costs a round trip. If assets are fingerprinted (app.3f9a1c.js), serve them with a long max-age and immutable so the browser does not revalidate at all.

Gotchas

Related explainers

← All HTTP status codes