304 Not Modified: The Cache‑Friendly Response
If-Modified-Since or If-None-Match, the server checks whether the resource has changed. If it hasn't, the server responds with 304, no response body, and instructs the client to use its cached copy. This saves bandwidth and reduces server load.
How Conditional Requests Work
The client includes one of these headers in a GET request:
- If-Modified-Since – the client sends the timestamp of its cached version. If the resource has been modified after that time, the server returns the full resource (200 OK); otherwise, 304 Not Modified.
- If-None-Match – the client sends an ETag (entity tag) of its cached version. If the server's current ETag matches, the resource hasn't changed → 304; otherwise, 200 with the new resource.
The server must include ETag and Last-Modified headers in its 200 responses to enable this mechanism.
Example Flow
| Step | Direction | HTTP Message |
|---|---|---|
| 1 | Client → Server | GET /style.css HTTP/1.1 |
| 2 | Server | Checks last modified time of style.css. |
| 3 | Server → Client | HTTP/1.1 304 Not Modified(no body, client uses cached version) |
Required Headers
A 304 response must include:
- No response body – the body must be empty.
- Cache-Control – to indicate how long the client should keep the cached copy.
- ETag or Last-Modified – the same values as the original resource (so the client can update its cache).
- Optionally, Expires or other caching headers.
Benefits of 304
- Bandwidth savings – no need to retransmit the full resource if it hasn't changed.
- Reduced server load – less processing and data transfer.
- Faster page loads – the client can render the page immediately using the cache.
- Better user experience – especially on mobile networks.
Comparison with 200 OK
| Status | Response Body | Condition |
|---|---|---|
| 200 OK | Full resource | Resource changed since last request (or no conditional headers). |
| 304 Not Modified | Empty | Resource unchanged; client's cached copy is valid. |
Implementing 304 on Your Server
Most web servers (Apache, Nginx, IIS) handle 304 automatically if you send appropriate Last-Modified and ETag headers. For static files, it's built‑in. For dynamic content, you may need to implement conditional logic in your application.
Nginx example (automatic):
Frequently Asked Questions
Is 304 Not Modified a redirect?
Technically it's a redirection status (3xx), but it's not a redirect to another URL. It's a "redirect" to the client's own cache. The browser interprets 304 as "use your cached copy."
Does 304 affect SEO?
No, 304 is a caching‑related status. It doesn't impact search rankings directly, but it improves site speed, which can indirectly benefit SEO.
Can I force the server to return 304?
Not directly. You can influence it by sending If-Modified-Since or If-None-Match headers, but the server decides whether the resource has changed.