More
More
304 Not Modified
The cached copy the client already has is still current, so no body is sent.
- Code
304- Reason phrase
- Not Modified
- Class
- 3xx Redirection
- Defined in
- RFC 9110 section 15.4.5
- Cacheable by default
- No
What it means
Redirection: the client has to take another step, usually following a Location header, to complete the request.
When a server should send it. In answer to a conditional GET or HEAD (If-None-Match or If-Modified-Since) when the client's cached copy is still current. Send the same validators (ETag, Last-Modified) and caching headers a 200 would have had, and no body.
Common causes. The browser asked with If-None-Match or If-Modified-Since and nothing changed.
What to do. Nothing; this is caching working. If users see stale content, the server is sending the same ETag or date after changes.
How clients and crawlers treat it
Browsers and HTTP clients. Browsers reuse the copy in their cache and show it as if it had just been downloaded. Developer tools list the request with status 304; the page itself never sees the difference.
Google Search. Tells Google the content is the same as at the last crawl; the indexing pipeline may recalculate signals for the URL, but otherwise it has no effect on indexing. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not stored on its own: a cache uses it to refresh the headers of the copy it already holds and keeps serving that copy (RFC 9111 section 4.3.4).
Example response
HTTP/1.1 304 Not Modified ETag: "5f8e-6a1b2c" Cache-Control: max-age=600 (no body)
How to send 304
# Static files: nginx sends 304 itself when the ETag or # Last-Modified date matches. Keep these on (the default): etag on; if_modified_since exact;
$etag = '"' . md5($body) . '"';
header('ETag: ' . $etag);
if (($_SERVER['HTTP_IF_NONE_MATCH'] ?? '') === $etag) {
http_response_code(304);
exit;
}
echo $body;
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 200OKThe request succeeded and the response carries the result.
- 412Precondition FailedA condition in the request headers, such as If-Match, was not met.
- 206Partial ContentThe server is sending only the part of the file the client asked for in its Range header.
All status codes · All 3xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.