请求:请求是由浏览器生成的,包括:
<request-line>请求类型(get/post)、访问的资源、http版本
<head>
<blank-line>
<body>
四个部分组成。其中头部信息包括:host,userAgent,connection,content-type(请求的编码方式),content-length,accept(接受的MIME类型),accept-charset,accept-Encoding,cookie,If-Modified-Since,pragma,referer(是从哪个页面跳转过来的)
响应是由服务器生成的,包括:
<status-line>
<head>
<blank-line>
<body>
其中head规定了catch-control,Date(响应的时间),LastModified,Etag
缓存是这样一个机制:
浏览器想请求一个资源-》查看缓存,发现资源过期了-》发现资源有lastModified和Etag->请求头部带上If-modified-since和If-None-Match-》服务器判定资源是不是修改过-》决定200重新发送还是304用缓存。
原文:http://www.cnblogs.com/wmx--/p/4365962.html