304

Not Modified

Official
The resource does not need to be retransmitted because no change has taken place

Specification of the HTTP status code 304

The 304 Not Modified status code indicates that a conditional GET or HEAD request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition evaluated to false. In other words, there is no need for the server to transfer a representation of the target resource because the request indicates that the client, which made the request conditional, already has a valid representation; the server is therefore redirecting the client to make use of that stored representation as if it were the content of a 200 (OK) response.

The server generating a 304 Not Modified response MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request:

  1. Content-Location, Date, ETag, and Vary
  2. Cache-Control and Expires (see [CACHING])

Since the goal of a 304 Not Modified response is to minimize information transfer when the recipient already has one or more cached representations, a sender SHOULD NOT generate representation metadata other than the above listed fields unless said metadata exists for the purpose of guiding cache updates (e.g., Last-Modified might be useful if the response does not have an ETag field).

Requirements on a cache that receives a 304 Not Modified response are defined in Section 4.3.4 of [CACHING]. If the conditional request originated with an outbound client, such as a user agent with its own cache sending a conditional GET to a shared proxy, then the proxy SHOULD forward the 304 Not Modified response to that client.

A 304 Not Modified response is terminated by the end of the header section; it cannot contain content or trailers.

Source / Quote by: The 304 Not Modified HTTP Status Code is specified by section 15.4.5 of RFC9110.

HTTP-Protocol

work in progress

How to throw a 304 statuscode with PHP?

To throw the HTTP status code 304 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(304) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 304 HTTP status code

In order to be able to display the HTTP status code (in this case 304 Not Modified) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 304 Not Modified
Overview
URL: https://http-statuscode.com/errorCodeExample.php?code=304
Status: 304 Not Modified
Those: Network
IP address: XX.XX.XX.XX
Status code 304 Not Modified

Browser compatibility of the 304 status code

Chrome Yes
Edge Yes
Firefox Yes
Opera Yes
Safari Yes
Chrome Android Yes
Firefox for Android Yes
Opera Android Yes
Safari on iOS Yes
Internet Yes
WebView Android Yes

Constants in programming languages

http.StatusNotModified
Response::HTTP_NOT_MODIFIED
:not_modified

Blog Articles

Caching and HTTP status codes: Optimizing web performance through intelligent caching

Web performance and the resulting user experience are central aspects for the success of any website. One significant factor that affects this performance is HTTP status codes, especially in the co...

Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.

LinkedInGitHub