当前位置:网站首页>Thoroughly understand browser strong cache and negotiation cache
Thoroughly understand browser strong cache and negotiation cache
2022-07-02 15:38:00 【Mr. fingertip dancer】
At work , After the front-end code is packaged, the generated static resources will be published to the static server , At this time, we need to do some operation and maintenance configuration for these static resources , among ,gzip And setting the cache is essential . These two are the most direct impact on website performance and user experience .
The advantages of caching :
- Reduce unnecessary data transmission , Save bandwidth
- Reduce the load on the server , Improve website performance
- Speed up the client to load web pages
- User experience friendly
shortcoming :
- If the resources are changed, but the client does not update in time, it will cause users to get information lag , If the old version had bug Words , It's going to get worse .
One . Strong cache
What is strong caching ? Where is the strength ? In fact, strong means mandatory . When the browser asks for a file , The server is in respone header Cache configuration is made for the file . Cache time 、 The cache type is controlled by the server , Specific performance: :
respone header Of cache-control, Common settings are max-age public private no-cache no-store etc.

Strong cache summary
cache-control: max-age=xxxx,public
Both the client and the proxy server can cache this resource ;
The client is in xxx Within the validity period of seconds , If there is a need to request the resource, read the cache directly ,statu code:200 , If the user does a refresh operation , Send it to the server http requestcache-control: max-age=xxxx,private
Only the client can cache this resource ; The proxy server does not cache
The client is in xxx Read the cache directly within seconds ,statu code:200cache-control: max-age=xxxx,immutable
The client is in xxx Within the validity period of seconds , If there is a need to request the resource, read the cache directly ,statu code:200 , Even if the user does a refresh operation , And don't send a message to the server http requestcache-control: no-cache
Skip setting strong cache , However, it does not prevent setting the negotiation cache ; Generally, if you do strong caching , Only when the strong cache fails can the negotiation cache be used , Set up no-cache You won't strengthen the cache , Each request will ask the server back .cache-control: no-store
Don't cache , This will make the client 、 Servers don't cache , There is no so-called strong cache 、 Negotiation cache .
Two 、 Negotiate the cache
The strong cache mentioned above is to set an expiration time for resources , Every time a client requests a resource, it will see whether it has expired ; Only when it expires will you ask the server . therefore , The purpose of strong caching is to give the client self-sufficiency . And one day , When the client requests the resource, it finds that it has expired , This is to request the server , At this time, the negotiation cache can be set in the process of requesting the server . Now , Negotiation caching requires interaction between the client and the server .
reference :https://www.jianshu.com/p/9c95db596df5
边栏推荐
- Bing.com網站
- 2303. 计算应缴税款总额
- Infra11199 database system
- Redux - detailed explanation
- Evaluation of embedded rz/g2l processor core board and development board of Feiling
- 【LeetCode】283-移动零
- 语义分割学习笔记(一)
- [leetcode] 877 stone game
- Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
- SQL transaction
猜你喜欢

【LeetCode】1162-地图分析

【网络安全】网络资产收集

Bing.com网站

Redux——详解

06_ Stack and queue conversion

19_ Redis_ Manually configure the host after downtime

03. Preliminary use of golang
![[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)](/img/cf/38e4035c3b318814672f21c8a42618.jpg)
[development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)

SQL transaction

Basic knowledge of cryptography
随机推荐
QML pop-up frame, customizable
NBA player analysis
XML Configuration File
[leetcode] 1905 statistics sub Island
损失函数与正负样本分配:YOLO系列
Basic knowledge of cryptography
Storage read-write speed and network measurement based on rz/g2l | ok-g2ld-c development board
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
Bing. Com website
MD5 encryption
04. Some thoughts on enterprise application construction after entering cloud native
yolo格式数据集处理(xml转txt)
[leetcode] 189 rotation array
夏季高考文化成绩一分一段表
终于搞懂了JS中的事件循环,同步/异步,微任务/宏任务,运行机制(附笔试题)
Beijing rental data analysis
【LeetCode】486-预测赢家
Leetcode skimming -- sum of two integers 371 medium