HTTP cache header Last-Modified and ETag analysis

Source: Internet
Author: User
Tags ranges webp microsoft iis


First request

Request:
Reference content
GET/pic/201408/102 .jpg HTTP/1.1
Host: www.111cn.net
Connection: keep-alive
Cache-Control: no-cache
Accept: image/webp, */*; q = 0.8
Pragma: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
Referer: http://www.111cn.net/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN, zh; q = 0.8

Response:
Reference content
HTTP/1.1 200 OK
Content-Length: 66529
Content-Type: image/jpeg
Last-Modified: Tue, 19 Aug 2014 12:23:54 GMT
Accept-Ranges: bytes
ETag: "029e570a8bbcf1: 1ae2"
Server: Microsoft-Microsoft IIS/6.0
X-Powered-By: ASP. NET
Date: Wed, 20 Aug 2014 00:29:03 GMT

Xxx

Second request

Request:
Reference content
GET/pic/201408/102 .jpg HTTP/1.1
Host: www.111cn.net
Connection: keep-alive
Cache-Control: max-age = 0
Accept: image/webp, */*; q = 0.8
Pragma: no-cache
If-Modified-Since: Tue, 19 Aug 2014 12:23:54 GMT
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36
If-None-Match: "029e570a8bbcf1: 1ae2"
Referer: http://www.111cn.net/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN, zh; q = 0.8

Response:
Reference content
HTTP/1.1 304 Not Modified
Last-Modified: Tue, 19 Aug 2014 12:23:54 GMT
Accept-Ranges: bytes
ETag: "029e570a8bbcf1: 1ae2"
Server: Microsoft-Microsoft IIS/6.0
X-Powered-By: ASP. NET
Date: Wed, 20 Aug 2014 00:29:54 GMT

HTTP cache is used to save the amount of data transmitted over the network. If the server resources do not change, 304 is returned and the content is blank. Last-Modified and ETag are both used for HTTP caching. The browser sends the second request to the server to determine whether the resource has changed. ETag was introduced at the beginning of the HTTP/1.1 standard. It supplemented Last-Modified for the following reasons:

· For some files that are periodically modified, the modification time has changed but the content has not changed. You do not want to GET the files again;
· Some files are frequently Modified. For example, the Last-Modified value can only be accurate to seconds after being Modified multiple times in one second;
· The exact modification time of files cannot be obtained on some servers;

Note: the HTTP/1.1 standard does not specify what the Etag content is or how to implement it. The only rule is that the Etag must be enclosed in quotation marks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.