Http code: What does 304 mean? How much do you know?

Http code: What does 304 mean? How much do you know?

picture

1. http code 304 Not Modified

The HTTP status code 304 Not Modified is a no-content status code that indicates that the client sent a conditional request and the server found that the resource has not changed since the last request, so it returns this status code instead of retransmitting the same data.

When a client (usually a browser) requests a resource from a server, if the resource has been cached before, it will include some information in the request header, such as If-Modified-Since or If-None-Match, to ask the server whether the resource has been modified.

  • If-Modified-Since: The client tells the server that it has not retrieved the resource since a certain date.
  • If-None-Match: The client tells the server that it has a specific version of the resource (identified by the ETag) and asks whether this version is still valid.

If the server finds that the requested resource has not changed since the last request, it sends a 304 Not Modified response without including the actual content of the resource. This reduces bandwidth consumption and improves performance because the client can directly use its cached copy.

1.1. Example

1.1.1. Client request header example:

 GET /example.html HTTP/1.1 Host: www.example.com If-Modified-Since: Tue, 15 Nov 2022 12:45:26 GMT

1.1.2. Server response header example:

 HTTP/1.1 304 Not Modified Date: Tue, 28 Oct 2024 12:30:00 GMT Last-Modified: Tue, 15 Nov 2022 12:45:26 GMT Cache-Control: max-age=3600

In this example, the client provides an If-Modified-Since header indicating that it has a copy of the resource that has not been updated since the specified date. The server checks the resource and determines that it has not been modified since that date, so it returns a 304 Not Modified response.

For front-end developers, understanding the 304 Not Modified response can help optimize application performance, especially when network requests are frequent. Proper use of HTTP caching mechanisms can significantly reduce data transmission and improve user experience.

<<:  Eight major IT disasters in 2024

>>: 

Recommend

A glimpse of the "treasure" in the tube: the last piece of cake for operators

Global Internet giants are accelerating their pen...

These three essential home gigabit network upgrade strategies

At present, the home broadband access provided by...

I experienced 5G network on Beijing Line 16 for a while and used up 7GB of data

What is 5G? Do I need to change my SIM card? Can ...

Critical documentation in data center transformation

Documentation is often neglected in IT work. When...

Cloud computing in 2018: Switch or die

Cloud computing technology is creating a new and ...

[Security Alert] Baota Panel suspected vulnerability or Nginx abnormality

For the convenience of many friends, panels are d...

6G is coming, how will the business change?

The next generation (6G) transmission technology ...

HostDare: 35% off KVM in Los Angeles, starting at $25.99/year

HostDare is a foreign VPS hosting company founded...