304 Not Modified HTTP Status Code

Description

HTTP status code 304, also known as "Not Modified," is used to indicate that the requested resource has not been modified since the last request. This status is typically used in conditional GET requests to reduce network bandwidth usage by utilizing cached data. When a web browser or client makes a request to a web server for a resource (like an image or a webpage), it can include headers such as If-Modified-Since or If-None-Match that contain a timestamp or an entity tag (ETag) respectively. These headers allow the server to determine if the requested resource has changed since the last time the client downloaded it.

If the server finds that the resource has not been modified since the provided timestamp or matches the ETag, it will respond with a 304 status code. This tells the client to use the version of the resource it has cached locally, instead of sending a new copy of the resource over the network. The response will not contain the resource's content since the server expects the client to use the cached version.

This mechanism is beneficial for optimizing web performance and reducing server load by minimizing unnecessary data transfer over the internet. It's especially useful for resources that don't change frequently, such as images, CSS, or JavaScript files.

Status

HTTP
304 Not Modified

Common Causes

Here are the primary causes or scenarios when a server might send a 304 response:

  1. Conditional GET Requests: A client (such as a web browser) sends a request to the server with headers like If-Modified-Since or If-None-Match. These headers include a timestamp or an entity tag (ETag) respectively, indicating the version of the resource the client already has. If the server determines that the resource has not changed since that timestamp or still matches the provided ETag, it will respond with a 304 status code, indicating that the cached version of the resource on the client side can still be used.

  2. Efficient Caching: The 304 status code is a key component of efficient caching mechanisms on the web. It allows servers to inform clients that they can continue to use the versions of resources they have cached, instead of sending those resources again. This reduces bandwidth usage and speeds up web page loading times, since only the headers need to be sent without the body of the response.

  3. Conditional Headers: The server relies on conditional request headers (If-Modified-Since, If-Unmodified-Since, If-Match, If-None-Match) to determine whether the resource has been modified. If the evaluation of these headers suggests no change in the resource, a 304 response is sent.

  4. Proactive Caching Policies: Websites can specify caching policies through headers like Cache-Control and Expires. These policies can instruct clients and intermediaries (like proxies and CDNs) on how long to cache resources. A 304 status code plays a crucial role in such policies by allowing servers to validate cached resources without needing to resend them.

  5. Reduced Server Load: By allowing clients to reuse cached resources, the server workload is reduced since it does not need to resend unchanged resources. This can lead to significant performance improvements for websites with high traffic or large resources.

  6. Last-Modified and ETag Headers: Servers use the Last-Modified and ETag response headers to provide timestamps and validators that clients use in subsequent conditional requests. If the server determines that the resource has not been modified (based on these values), it will send a 304 status code.

In essence, the 304 status code is a tool for optimizing web performance and reducing unnecessary data transfers, making it a critical component of the HTTP protocol's caching mechanisms.

Browser Support

The following table will show you the current browser support for the 304 Not Modified HTTP status code.

Desktop
Edge Chrome Firefox Opera Safari
YesYesYesYesYes
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
YesYesYesYesYesYes

Last updated by CSSPortal on: 31st March 2024