304 Not Modified
The HTTP304 Not Modifiedredirection response status code indicates that there is no need to retransmit the requested resources.
This response code is sent when the request is aconditionalGET orHEAD request with anIf-None-Match or anIf-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 a200 OK response with the resource if the condition evaluated to 'true'.SeeHTTP caching for more information.
The response must not contain a body and must include the headers that would have been sent in an equivalent200 response, such as:
Note:Manydeveloper tools' network panels of browsers create extraneous requests leading to304 responses, so that access to the local cache is visible to developers.
In this article
Status
304 Not ModifiedExamples
>304 response to conditional requests
The examples below showGET requests made usingcurl with conditional request headers.The--http1.1 flag is used to force the HTTP/1.1 protocol for readability.
The first request uses anIf-Modified-Since condition with a future date of 21st November 2050.This must evaluate tofalse, because the resource can't have been updated after a time that hasn't happened yet:
curl --http1.1 -I --header 'If-Modified-Since: Tue, 21 Nov 2050 08:00:00 GMT' \ https://developer.mozilla.org/en-US/This will result in the following HTTP request:
GET /en-US/ HTTP/1.1Host: developer.mozilla.orgUser-Agent: curl/8.7.1Accept: */*If-Modified-Since: Tue, 21 Nov 2050 08:00:00 GMTThe response would be200 OK with the current version of the resource if the resource had been updated after the timestamp in theIf-Modified-Since header.Instead, we get a304 response that includesETag,Age andExpires headers, telling us our cached version of the resource is still current:
HTTP/1.1 304 Not ModifiedDate: Wed, 28 Aug 2024 09:52:35 GMTExpires: Wed, 28 Aug 2024 10:01:53 GMTAge: 3279ETag: "b20a0973b226eeea30362acb81f9e0b3"Cache-Control: public, max-age=3600Vary: Accept-EncodingX-cache: hitAlt-Svc: clearNow run anothercurl command using theetag value from the previous response with theIf-None-Match condition (since thisetag is the current version of the resource on the server we expect to receive a304 Not Modified response):
curl --http1.1 -I --header 'If-None-Match: "b20a0973b226eeea30362acb81f9e0b3"' \ https://developer.mozilla.org/en-US/This will result in the following HTTP request:
GET /en-US/ HTTP/1.1Host: developer.mozilla.orgUser-Agent: curl/8.7.1Accept: */*If-None-Match: "b20a0973b226eeea30362acb81f9e0b3"Because theetag value matches at the time of the request, the entity tag fails the condition, and a304 response is returned:
HTTP/1.1 304 Not ModifiedDate: Wed, 28 Aug 2024 10:36:35 GMTExpires: Wed, 28 Aug 2024 11:02:17 GMTAge: 662ETag: "b20a0973b226eeea30362acb81f9e0b3"Cache-Control: public, max-age=3600Vary: Accept-EncodingX-cache: hitAlt-Svc: clearSpecifications
| Specification |
|---|
| HTTP Semantics> # status.304> |
Compatibility notes
Browser behavior differs if this response erroneously includes a body on persistent connections.See204 No Content for more details.