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.