当前位置:网站首页>Understanding of strong caching and negotiation caching
Understanding of strong caching and negotiation caching
2022-06-29 18:32:00 【Spongebob_ nut】
cache It refers to the resource copy saved in the proxy server or client disk . Using the cache can reduce access to the server , Therefore, the communication flow and communication time are saved .
Browser caching is to save resources , And it can speed up the speed of browsing the website , When a user visits a web page for the first time , The browser saves the requested document on the user's disk , When the second visit , It will be displayed directly from the local , Thus, the access speed of the page is improved .
Advantages of browser caching :
- Reduced redundant data transfer , Save network fee ;
- Reduced server burden , Greatly improve the performance of the website ;
- Speed up client loading web pages ;
Browser cache is divided into Strong cache and Negotiate the cache .
- When the browser makes a resource request , It will determine whether the request header hits the strong cache , If hit , Read cache directly from local , No request is sent to the server .
- When the strong cache fails to hit , Will send a request to the server , Determine whether the negotiation cache hit , If hit , The server will return the request , No resources will be returned , Tell the browser to read the cache locally ; If you don't hit , The server directly returns the resource .
difference :
Strong cache hit , The server will not be requested , Direct request cache ; Negotiate cache hits , Will request the server , No content will be returned , Then read the cache .
from memory cache and from disk cache The difference between :
from memory cache: Literally from memory , This resource is taken directly from memory , The server will not be requested , Generally, the resource has been loaded and cached in memory , When you close the page , The resource is freed by memory , Reopening the same page again is , There will be no from memory cache The situation of .
from disk cache: This resource is taken from the disk , This resource was also loaded at a certain time before , The server will not be requested , However, this resource will not be released when the page is closed , Because this resource is stored in the hard disk , Next time you open it, it will still from disk cache.
One 、 Strong cache
Strong cache , utilize HTTP Return to... In the head expires and cache-control Two fields to control , The cache time used to represent the resource ( Validity of cache ).
This method will have a fixed time , But if the server data is updated , If the validity period of the strong cache has not expired , The data cannot be updated .
Expires
The field is http1.0 The norm of time , Its value is GMT Absolute time of format , When the browser makes the first request , The server will add... To the return header Expires, Next time request , If you hit the cache before this time .
Cache-Control
This value is based on max-age Determine the cache life cycle , Is in seconds , If in the life cycle time , Then hit cache .
Two 、 Negotiate the cache
Negotiate the cache , It is up to the server to determine whether cache resources are available , Therefore, the client and the server should communicate through some kind of identity , So that the server can judge whether the request resource can be accessed by cache .
utilize Last-Modified,If-Modified-Since and ETag,If-None-Match To achieve .
Last-Modified,If-Modified-Since
Last-Modified: Represented as the head part of the entity ,response return , Indicates the last update time of the resource ;
If-Modified-Since: By comparing the two times, we can determine whether the resource has been modified during the request , If not modified , Cache negotiation hits , The browser reads resources from the cache , If you don't hit , Resource has been modified , Returns a new Last-Modified Time and server resources .
ETag,If-None-Match
In some cases, it is not enough to judge the last modification date to verify whether the resource has been changed :
- There is a periodic rewrite of some resources , However, the actual content of resources has not changed ;
- The modified information is not important , Such as notes, etc ;
- Last-Modified Cannot be accurate to milliseconds , However, the update frequency of some resources is sometimes less than one second .
ETag: In response to the header field , A unique identifier that represents the content of a resource , With the server response return ;
If-None-Match: The server compares... In the request header If-None-Match And... In the current resource etag Is it consistent , To determine whether the resource has been modified , If not modified , Then hit cache , The browser reads resources from the cache , If it has been modified , The server will return a new etag, And return the resource .
The first time the browser requests :

When the browser makes a subsequent request :

The difference between strong cache and negotiation cache :
| Cache type | Access to resources in the form of | Status code | Send request to server |
|---|---|---|---|
| Strong cache | Fetch... From cache | 200(from cache) | no , Get directly from the cache |
| Negotiate the cache | Fetch... From cache | 304(Not Modified) | yes , Let the server know if the cache is available |
边栏推荐
- Usage of BeanUtils property replication
- mysql — 清空表中数据
- [wangdingbei 2020 Qinglong formation]areuserialz
- 3H proficient in opencv (VII) - color detection
- Workflow module jar package startup error: liquibase – waiting for changelog lock
- Markdown knowledge comes gently
- 2022.6.29-----leetcode.535
- Fluent's MSH grid learning
- Sd6.23 summary of intensive training
- Xiaobai yuesai 51 supplement e g f
猜你喜欢

Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

美法官裁定,被控掩盖黑客行为的Uber前安全主管必须面对欺诈指控

山东大学项目实训(八)设计轮播图进入页面

How to use the oak camera on raspberry pie?
![报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket](/img/8a/ebad75daa581e22d50dddde49e1fac.jpg)
报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket
![Error [warning] neural network information was performed on socket 'RGB', depth frame is aligned to socket](/img/8a/ebad75daa581e22d50dddde49e1fac.jpg)
Error [warning] neural network information was performed on socket 'RGB', depth frame is aligned to socket

Servlet student management system (Mengxin hands-on version)

Xiaomai technology x hologres: high availability of real-time data warehouse construction of ten billion level advertising
MySql存储过程循环的使用分析详解
随机推荐
How QQ opens online customer service
How to use the oak camera on raspberry pie?
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
[tcapulusdb knowledge base] tcapulusdb system user group introduction
[tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction
markdown常用字体
Interview question 10.10 Rank of digital stream
Sd6.25 summary of intensive training
Dictionary tree (optional)
保持jupyter notebook在终端关闭时的连接方法
Image feature computation and representation -- content based image retrieval
Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
关于微服务
Let Google search your blog
Xiaobai yuesai 51 supplement e g f
Detailed analysis on the use of MySQL stored procedure loop
Stepping on the pit: json Parse and json stringify
VMware installation esxi
Application and practice of DDD in domestic hotel transaction -- Theory
mysql — 清空表中数据