304 Not Modified — ETag validation

Watch how ETag and If-None-Match turn a second request into a tiny 304 Not Modified. The difference between a 200 re-download and a cache hit, animated.

Scenario

Speed
FIRST REQUESTCONDITIONAL RE-REQUESTETAG CHANGEDBrowserServer1GET /app.css2200 OKETag: "v8a2c" + body 142KB— next visit —4GET /app.cssIf-None-Match: "v8a2c"5304 Not Modifiedno body — use cache304 is the heart of cache validation: a few hundred bytes of headers instead of 142KB. Huge on slow networks. Last-Modified/If-Modified-Since do the same job, but ETag is more precise.7GET /app.cssIf-None-Match: "v8a2c" (server: v9)8200 OKETag: "v9f1b" + new bodyBecause the ETag is content-based, cache invalidation is automatic: change the file and the fingerprint changes, so no client keeps stale copies.

Requests

3

Current step 9/9

Because the ETag is content-based, cache invalidation is automatic: change the file and the fingerprint changes, so no client keeps stale copies.

Request2xx success3xx redirect/cache4xx client error5xx server error

Arrow color = status class. The key redirect pair: 301 is 'permanent', 307 'keeps the method'. Notice how cheap the second request is when the cache validates (304).

All status codes

1xx Informational

100Continue'Go ahead' before a large body — the answer to Expect: 100-continue
101Switching ProtocolsProtocol switch approved — WebSocket upgrade is the classic case
103Early HintsHeaders sent before the final response — for Link preload hints

2xx Success

200OKThe standard success response
201CreatedA new resource was created — successful POST/PUT
202AcceptedAccepted but not processed yet — async work queued
204No ContentSuccess with nothing to return — common after DELETE
206Partial ContentOnly part of the resource — Range requests, video seeking, resumed downloads

3xx Redirection

300Multiple ChoicesMultiple choices to pick from — rarely used today
301Moved PermanentlyPermanent move — remembered by browsers/search engines, SEO transfers▶ Animate
302FoundTemporary move — original URL keeps its index; POST becomes GET by convention▶ Animate
303See Other'Go GET a different URL' — the standard for redirecting after POST (PRG)▶ Animate
304Not ModifiedCache validation passed — 'use your copy', no body sent▶ Animate
305Use ProxydeprecatedForced proxy use — deprecated over security concerns
307Temporary RedirectTemporary move, method/body preserved — the precise 302▶ Animate
308Permanent RedirectPermanent move, method/body preserved — the precise 301▶ Animate

4xx Client error

400Bad RequestThe request itself is malformed — bad syntax, broken parameters
401UnauthorizedNot authenticated — credentials needed; WWW-Authenticate hints the scheme▶ Animate
402Payment RequiredPayment required — reserved, with almost no standard use
403ForbiddenAuthenticated but not allowed — retrying changes nothing▶ Animate
404Not FoundNot here right now — the most famous code▶ Animate
405Method Not AllowedRight URL, wrong method — the Allow header lists what works
406Not AcceptableCan't produce a format you Accept — content negotiation failed
407Proxy Authentication RequiredProxy authentication needed — corporate proxy environments
408Request TimeoutThe server timed out waiting for the request
409ConflictConflicts with current state — concurrent edits, version mismatch
410GoneExplicitly deleted forever — deindexes faster than 404▶ Animate
411Length RequiredContent-Length is required and missing
412Precondition FailedA precondition like If-Match didn't hold
413Content Too LargeRequest body too large — upload size limit
414URI Too LongRequest URI too long
415Unsupported Media TypeContent-Type not supported
416Range Not SatisfiableRequested Range falls outside the resource
417Expectation FailedCan't satisfy the Expect header
418I'm a teapot'I'm a teapot' — 1998 April Fools' joke; some sites reuse it for rate limiting
422Unprocessable ContentWell-formed but semantically wrong — the standard for validation failures
425Too EarlyReplay risk — rejects 0-RTT early data
426Upgrade RequiredProtocol upgrade required — Upgrade header says to what
428Precondition RequiredConditional requests required — forces If-Match against lost updates
429Too Many RequestsToo many requests — rate limiting; pairs with Retry-After
431Request Header Fields Too LargeRequest headers too large — bloated cookies are the usual cause
451Unavailable For Legal ReasonsBlocked for legal reasons — censorship, DMCA; named after Fahrenheit 451

5xx Server error

500Internal Server ErrorServer code error — the most common 5xx▶ Animate
501Not ImplementedNot implemented — the server doesn't support that method/feature
502Bad GatewayGateway couldn't reach the upstream — a middle-layer problem▶ Animate
503Service UnavailableTemporarily unavailable — overload or maintenance; pairs with Retry-After▶ Animate
504Gateway TimeoutUpstream didn't respond in time — slow queries, timeout misconfig
505HTTP Version Not SupportedThe requested HTTP version isn't supported
507Insufficient StorageServer out of storage — WebDAV
508Loop DetectedInfinite loop detected — WebDAV circular references
511Network Authentication RequiredNetwork auth required — captive portals (Wi-Fi login pages)

HTTP cache validation works on a simple idea: if nothing changed, don't resend the body. The first response carries an ETag — a fingerprint of the content. On the next request the browser sends If-None-Match saying 'here's the fingerprint I have'; if it still matches, the server answers 304 Not Modified with no body at all.

304 lives in the 3xx class — it means 'go to your cache', not 'success'. A few hundred bytes of headers instead of a 142KB stylesheet makes a real difference on slow networks, and combined with CDN caches it slashes origin load.

Last-Modified/If-Modified-Since is the same mechanism based on dates instead of fingerprints. ETag wins on precision — a file whose mtime changed but content didn't still validates. Note that Cache-Control: max-age is even cheaper than 304: while fresh, the browser doesn't send any request at all. HTTP Status Playground

Frequently asked questions

Is 304 an error? I keep seeing it in dev tools.
No — it's proof the cache worked. A 304 means the browser asked 'has this changed?' and the server said 'no', so the body came from local cache. '(from disk/memory cache)' is an even stronger hit that skipped validation entirely.
How do ETag and Cache-Control differ?
Cache-Control: max-age tells the browser 'don't even ask for N seconds' — zero requests. After it expires, ETag/If-None-Match kicks in and produces the 304. They complement each other; the ideal setup uses both.
How do I force cache invalidation when a file changes?
Cache busting: put a content hash in the filename (app.a3f2c1.js). A new name means a new resource — the browser fetches it unconditionally. Keep HTML on no-cache so it always references the latest filename.

Other scenarios

Related tools