The technology set up above is the server side of a person in the effort, and sometimes need to cooperate with the client.
A link request process can be roughly divided into several phases
If the client sends the same request, and the result is the same, can we buffer it? Is it possible to reduce the number of steps?
Yes, in general, there are a few ways to do this:
1. We first try to buffer on the service side, we try to send the content of a long link has been returned without release, the next request directly back to send the content, this does not apply to frequent access, for a number of special situations, special requests.
2. For static files have the last modification time LastUpdateTime, the first time the client requested the return HTTP header contains this lastupdatetime, then the client will add the page to the cache, the second request header contains LastUpdateTime, The service side compares it to the current lastupdatetime, and if so, directly tells the client that the file has not been modified, directly in your cache.
In fact, the field of HTTP return header save update time is last-modified, and the field of the request header is If-modified-since
Such as
Return header
http/1.1 OK
Date:wed, Mar 2013 07:35:22 GMT
content-type:text/html; Charset=utf-8
Content-encoding:gzip
Last-modified:wed, Mar 2013 07:35:22 GMT
Transfer-encoding:chunked
Server:yumeiz
Request Header
get/http/1.1
Host:www.xxx.com
Connection:keep-alive
If-modified-since:wed, Mar 2013 07:35:22 GMT
Return to Baotou again:
http/1.1 304 Not Modified
For some dynamic requests without modification time, the server can contract a field, and when the second request finds that the field has not changed, it also tells the client to use the content directly in the cache.
In fact, this field is ETag, and the field of the request header is If-none-match
Such as
Return header (only point to corresponding field, others consistent with above)
Etag= "ABCD"
Request Header
if-none-match=w/"ABCD"
Through the above we know that when the client received a 304 not Modified Baotou, it means you can directly use the cached pages, for some frequently requested files such as JS,CSS has a small role, there are some large image files, means to send a life-saving road grass ...