304 Not Modified
The HTTP
304 Not Modified redirection response status code indicates that there is no need to retransmit the requested resources.This response code is sent when the request is a conditional
GET or HEAD request with an If-None-Match or an If-Modified-Since header and the condition evaluates to 'false'.
It confirms that the resource cached by the client is still valid and that the server would have sent a 200 OK response with the resource if the condition evaluated to 'true'.
See HTTP caching for more information.The response must not contain a body and must include the headers that would have been sent in an equivalent
200 response, such as:Note:
Many developer tools' network panels (external) of browsers create extraneous requests leading to
304 responses, so that access to the local cache is visible to developers.Status
Examples
304 response to conditional requests
The examples below show
GET requests made using curl (external) with conditional request headers.
The --http1.1 flag is used to force the HTTP/1.1 protocol for readability.The first request uses an
If-Modified-Since condition with a future date of 21st November 2050.
This must evaluate to false, because the resource can't have been updated after a time that hasn't happened yet:This will result in the following HTTP request:
The response would be
200 OK with the current version of the resource if the resource had been updated after the timestamp in the If-Modified-Since header.
Instead, we get a 304 response that includes ETag, Age and Expires headers, telling us our cached version of the resource is still current:Now run another
curl command using the etag value from the previous response with the If-None-Match condition (since this etag is the current version of the resource on the server we expect to receive a 304 Not Modified response):This will result in the following HTTP request:
Because the
etag value matches at the time of the request, the entity tag fails the condition, and a 304 response is returned:Specifications
| Specification |
|---|
| HTTP Semantics # status.304 (external) |
Compatibility notes
Browser behavior differs if this response erroneously includes a body on persistent connections.
See
204 No Content for more details.
