当前位置:网站首页>Browser cache execution process

Browser cache execution process

2022-06-13 00:11:00 PS cool tutorial

HTTP Fields related to page caching in the protocol , Let's meet first :

header explain
Expires Cache expiration date and time
Cache-Control Set cache related configuration information
Last-Modified Last modification time of the requested resource
ETag The current value of the entity tag of the request variable , For example, the file MD5 value

 Insert picture description here
(1) The user sends a request to the server through the browser for the first time to obtain data , The client has no corresponding cache , So you need to send request Request to get data ;

(2) After the server receives the request , After obtaining the data of the server and the permission of the server cache , return 200 And attach the corresponding resources and cache information on the response header ;

(3) When the user accesses the same resource again , The client will search the cache directory of the browser for the existence of the response cache file

(4) If the corresponding cache file is not found , Then go (2) Step

(5) If there is a cache file , Next, judge whether the cache file is expired , The criterion of expiration is (Expires),

(6) If it doesn't expire , Then directly return data from the local cache for display

(7) If Expires Be overdue , Next, you need to determine whether the cache file has changed

(8) There are two criteria for judging , One is ETag(Entity Tag), One is Last-Modified

(9) The judgment result is that there is no change , The server returns 304, Get data directly from the cache file

(10) If the judgment has changed , Get data from the server again , And negotiate according to the cache ( Whether the server needs to set the cache data ) To cache data .

原网站

版权声明
本文为[PS cool tutorial]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130007457751.html