HTTP request header tag with If-Modified-Since Last-Modified

1. Basic definitions

Last-Modified and If-Modified-Since HTTP request header is a standard label for the recording was last modified pages.

2. Send direction

Last-Modified was sent by the server to the client HTTP request header tag

If-Modified-Since it is sent by the client to the server HTTP request header tag

3. scenarios

(1)Last-Modified

When the browser first request a particular URL, the server returns the status is 200, the content is the resource you request, but there is a Last-Modified attribute tag the file was last modified at period end service time, similar to the format such:

Last-Modified: Fri, 12 May 2006 18:53:33 GMT

The time is back with the server to store the file modification time

(2)If-Modified-Since

When the client makes a second request this URL, in accordance with the provisions of the HTTP protocol, the browser sends If-Modified-Since header to the server, after asking whether the time of the file has been modified:

If-Modified-Since: Fri, 12 May 2006 18:53:33 GMT

The time is now behind the local browser storage file modification time

If the server's resources does not change, the same time, automatically returns an HTTP status code 304 (Not Changed.) Status code, the content is then empty, the client received, directly to display the local cache file to the browser, thus saving the amount of transmission data.

If the server-side resources change or restart the server, time inconsistency, it returns an HTTP status code 200 and the new file contents, after receiving the client will discard the old file, the new file is cached and displayed in the browser.

The above operation can be guaranteed not to issue duplicate client resources, but also to ensure that when the server changes, the client can get the latest resources.
----------------
Original link: https://blog.csdn.net/lhl1124281072/article/details/80067764

Guess you like

Origin www.cnblogs.com/brendan/p/12636961.html