当前位置:网站首页>Talk about browser cache control
Talk about browser cache control
2022-04-23 16:42:00 【summer·】
Cache is a very important concept in computer field , Today, we mainly talk about the caching strategy in browsers
First, let's talk about the process when caching is needed :
Client initiated HTTP request , Server response
The response content contains the required data and cache rules ( Mark ) And the browser will store the data and cache rules in the browser cache
The client initiates the previous request again , You will ask the browser cache first with the cache rules , Whether the cache is out of date
If there is no expiration, the cached content will be returned directly , If it expires, send a request to the server again
The above process is actually divided into two methods : Strong caching and negotiation caching
Force memory and negotiation cache
` Every time the browser makes a request , Both look in the browser cache for the result of the request and the cache identity `
` Each time the browser gets the result of a returned request, it stores the result and the cache id in the browser cache `
Mandatory cache : Search the browser cache for the result of the request , And according to the caching rules of the result to decide whether to use the process of caching the result
There are three types of strong caching :
- There is no such cache result and cache identity , Force cache invalidation , Then send a request directly to the server ( Consistent with the first request )
- There is the cache result and the cache identity , But the result is no longer valid , Force cache invalidation , Then use negotiation cache ( Don't analyze )
- There is the cache result and the cache identity , And this result has not been invalidated , Force cache to take effect , Return the result directly
Cache rules that enforce caching :
When the browser makes a request to the server , The server will put the caching rules into HTTP In response to a message HTTP The header is returned to the browser along with the request result , The fields that control the forced cache are Expires and Cache-Control, among Cache-Control Priority ratio Expires high .
Expires yes HTTP/1.0 Control the fields in the Web Cache , Its value is the expiration time when the server returns the result cache of the request , When the request is initiated again , If the client time is less than Expires The value of , Use cached results directly
If the time between the client and the server is for some reason ( For example, different time zones ; Client and server have one side's time is not accurate ) There is an error , Then the forced cache will fail directly , In this way, the existence of forced cache is meaningless
Negotiate the cache : After the forced cache expires , The browser makes a request to the server with the cache id , The process by which the server determines whether to use the cache based on the cache identity
The difference from strong cache is that whether to use cache is decided by the server , Strong caching only cares about whether the cache in the cache rule expires
summary :
Force the cache to take precedence over the negotiation cache , If cache is forced (Expires and Cache-Control) Take effect and use the cache directly , If it does not take effect, a negotiation cache is performed (Last-Modified / If-Modified-Since and Etag / If-None-Match), The negotiation cache is up to the server to decide whether to use the cache , If the negotiation cache expires , Then represents the cache invalidation of the request , Retrieve request results , This is then stored in the browser cache ; Return in effect 304, Continue using the cache
版权声明
本文为[summer·]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231638221028.html
边栏推荐
- Modify the test case name generated by DDT
- Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
- Execution plan calculation for different time types
- Use case labeling mechanism of robot framework
- The first line and the last two lines are frozen when paging
- Knowledge points and examples of [seven input / output systems]
- Database dbvisualizer Pro reported file error, resulting in data connection failure
- 伪分布安装spark
- Pycham connects to the remote server and realizes remote debugging
- Regular filtering of Intranet addresses and segments
猜你喜欢
随机推荐
MySQL的btree索引和hash索引区别
扫码登录的原理你真的了解吗?
正则过滤内网地址和网段
MySQL master-slave replication
MySql主从复制
Sail soft segmentation solution: take only one character (required field) of a string
计组 | 【七 输入/输出系统】知识点与例题
信息摘要、数字签名、数字证书、对称加密与非对称加密详解
阿里研发三面,面试官一套组合拳让我当场懵逼
Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
JSP learning 3
Public variables of robotframework
Report FCRA test question set and answers (11 wrong questions)
面试百分百问到的进程,你究竟了解多少
How to quickly batch create text documents?
About background image gradient()!
Use case labeling mechanism of robot framework
无线鹅颈麦主播麦手持麦无线麦克风方案应当如何选择
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Nacos detailed explanation, something