Skip to content

HTTP Status Code 304 Not Modified

What is HTTP Response Status Code 304 Not Modified?

HTTP response status code 304 Not Modified indicates that the requested resource has not been modified since the last time it was requested. The client can use its cached version.

When is HTTP Response Status Code 304 Not Modified Used?

The 304 status code is used when a client sends a conditional request, like If-Modified-Since, to check if the resource has changed, and the server confirms that it hasn’t.

Significance of HTTP Response Status Code 304 Not Modified in Web Development?

The 304 status code helps improve performance by allowing clients to use cached content, reducing the load on servers and decreasing page load times for users.

How to Implement HTTP Response Status Code 304 Not Modified?

To implement a 304 status code, the server should validate conditional requests and return this code if the resource has not changed since the specified time.

FAQs

  • When should I use a 304 status code? Use it when serving cached content that hasn’t changed since the client’s last request.
  • Does 304 include a message body? No, a 304 response should not include a message body, only headers.
  • How does 304 benefit website performance? It reduces bandwidth and server load by allowing clients to use cached data.

What is HTTP Response Status Code 304 Not Modified?

HTTP response status code 304 Not Modified indicates that the requested resource has not changed since the last time it was requested. This status code allows the client to use its cached version of the resource, reducing the need for redundant data transfer.

When is HTTP Response Status Code 304 Not Modified Used?

The 304 status code is used when a client sends a conditional request using headers like `If-Modified-Since` or `If-None-Match`. The server checks if the resource has been modified since the specified time or version, and if it hasn’t, it returns a 304 status code, allowing the client to use the cached version.

Example 1: Using If-Modified-Since Header

# Client sends a GET request with If-Modified-Since header to check if the resource has been updated.
GET /images/logo.png HTTP/1.1
Host: www.example.com
If-Modified-Since: Wed, 08 Oct 2024 10:00:00 GMT

# Server Response
HTTP/1.1 304 Not Modified
Date: Wed, 09 Oct 2024 12:50:00 GMT
Server: Apache/2.4.41 (Ubuntu)

# The server indicates that the image has not been modified since the specified date.
# The client uses its cached version of the image, reducing the need for data transfer.

Example 2: Using If-None-Match Header

# Client sends a GET request with If-None-Match header to check for resource updates.
GET /api/data.json HTTP/1.1
Host: www.example.com
If-None-Match: "abc123"

# Server Response
HTTP/1.1 304 Not Modified
Date: Wed, 09 Oct 2024 12:55:00 GMT
Server: Nginx/1.18.0

# The server indicates that the JSON data has not changed since the last version with ETag "abc123".
# The client uses its cached version of the JSON data.

Summary

The HTTP 304 Not Modified status code is an essential part of optimizing web performance by allowing clients to use cached resources when they have not changed. It helps save bandwidth and reduce server load, as the server only needs to send headers without transferring the entire resource. Conditional headers like If-Modified-Since and If-None-Match enable clients to request updates only when a resource has changed, ensuring they use up-to-date information while minimizing unnecessary data transfer.

I am the founder of SEO Leaders and have been involved in the internet and web development in one way or another for over 20 years. Since founding SEO Leaders some 6 years ago I have been heavily involved in web develepment, Digital PR and technical SEO for a wide variety of projects. I hope to enlighten you on a wide range of topics related to my chosen profession!

Back To Top