HTTP 304 Not Modified: how conditional requests and ETags save bandwidth

Open this example in the tool

Try it in the tool

HTTP Status Codes

Every HTTP status code with its RFC, meaning and when to use it.

cURL to Code

Turn curl commands into fetch, axios, Python requests or Go.

HTTP 304 Not Modified answers a conditional request: the client already has a copy of the resource, it asks “has this changed?”, and the server replies that it has not. The reply contains only headers, so it is tiny. It is defined in RFC 9110, section 15.4.5.

How the exchange works

  1. The first response carries a validator, an ETag (a fingerprint of the content) and/or Last-Modified.
HTTP/1.1 200 OK
ETag: "33a64df5"
Last-Modified: Sun, 25 Oct 2026 08:00:00 GMT
Cache-Control: max-age=0, must-revalidate
  1. The next time, the browser repeats the request with the validator:
GET /app.css HTTP/1.1
If-None-Match: "33a64df5"
If-Modified-Since: Sun, 25 Oct 2026 08:00:00 GMT
  1. If the file did not change, the server answers 304 Not Modified with no body, and the browser uses its copy. If it changed, the server answers 200 with the new body and a new ETag.

You can try it with curl: curl -I -H 'If-None-Match: "33a64df5"' https://example.com/app.css shows 304 when the tag matches. Convert a request like that with the curl converter when you need to send it from code.

Why this matters

For a large file that rarely changes, a 304 saves the whole download. It also keeps a page lively: the check costs a round trip but no data. For files that never change under one name (a build output with a hash in the file name), the best answer is not a 304 but a long Cache-Control: max-age with immutable, which removes the round trip altogether.

What a correct 304 contains

The server must send the same headers that matter for caching as it would with the 200 (Cache-Control, ETag, Expires, Vary, Content-Location). If a 304 comes back without them, caches may forget their validators and the next request is a full download. A frequent bug is a framework that sends a 304 without the Cache-Control of the file.

When 304 does not happen

  • No validator: the file has no ETag or Last-Modified. Static servers add them by default, and application servers often do not.
  • An ETag that changes on every request, for instance if it is generated from the time or from a counter.
  • Several servers behind a load balancer that compute different ETag values for the same file (an old Apache setup built the tag from the inode number, which differs by machine).
  • The browser was told not to cache: Cache-Control: no-store removes the stored copy, so there is nothing to ask about.
  • DevTools with “Disable cache” ticked, which sends the request without validators.

Reading it in DevTools

In the Network panel, a 304 shows a status of 304 and a small size, while “(disk cache)” or “(memory cache)” means that the browser did not ask the server at all. A 304 is not a redirect even though it is in the 3xx range. The HTTP status codes tool explains each code in the 3xx range; open the example above for the wording and the RFC reference, and read 302 and 301 for the redirects.

Frequently asked questions

Is 304 an error?

No. It is a success of the cache: the browser asked whether its copy was still valid and the server said yes, without sending the file again. A page full of 304 responses is a healthy page.

Why do I never get a 304 for a file?

The response has neither an ETag nor a Last-Modified header, so the browser has nothing to ask with. Another cause is a server that builds a new ETag for every request, for example from a timestamp, or a proxy that strips the header.

What is the difference between a 304 and a response served from cache?

From cache means the browser did not contact the server at all, because the copy was still fresh (Cache-Control: max-age). A 304 means it did contact the server to check, and got a very small answer. A fresh copy is the faster of the two.

Can a 304 have a body?

No. A 304 response has no message body. If you see content, it is coming from the cache, not from the response.

More in this reference