② caching HTTP protocol

First, tell us about the HTTP message information is divided into two parts

    1. Include attribute header (header) --------------- additional information (cookie, cache information, etc.) associated with the cache of information rules, are included in the header

    2. The body part contains the data (body) ----------- HTTP request really wanted part of the transmission

Common cache can only cache resources get http request response.

HTTP caching is the second request from the beginning. The first time the resource request, the server returns a resource, and return the cache resource parameters in respone header header; the second request, the browser requests to determine these parameters, hit strong cache 200 directly, or put the request parameters plus to request header header to the server to see if a cache hit consultations, hit return 304, or the server returns a new resource.

HTTP caching roughly divided into two types, one is forced cache, the cache and the other is negotiated.

Forced Cache: (i.e., Cache-Control max-age is not expired or not expired Expires time buffer) in a case where cache data is not failure, then any request will be sent directly to the browser using the cache data, the server will no longer . This way the page loading speed is the fastest, performance is very good, but in the meantime, if the server resource changed, the page is out of reach, because it will no longer be sent from the server requests. This situation is often encountered in the development of our species, for example, you modify a style on the page, refresh the page but did not take effect, because walking is a strong cache.

Negotiation cache: when the Cache-Control and Expires or Cache-Control and also the Expires or its no-cache attribute is set when the first request response header returned by the server is not (i.e., not strength buffer), the browser section it will consult with the secondary server requests, compared with the server to determine whether the resource has been modified update. If the server's resources are not modified, then it will return a 304 status code that tells the browser can use the data in the cache, thus reducing the pressure on the server data transmission. If the data update status code 200 is returned, the server returns the resource and return the updated cache information together.

Reproduced in: https: //www.cnblogs.com/JiAyInNnNn/p/11014350.html

Guess you like

Origin blog.csdn.net/weixin_34331102/article/details/93543319