当前位置:网站首页>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
边栏推荐
猜你喜欢
Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
面试百分百问到的进程,你究竟了解多少
NVIDIA显卡驱动报错
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
人脸识别框架之dlib
The font of the soft cell changes color
JMeter setting environment variable supports direct startup by entering JMeter in any terminal directory
LVM and disk quota
RAID磁盘阵列与RAID5的创建
Use case execution of robot framework
随机推荐
众昂矿业:萤石浮选工艺
昆腾全双工数字无线收发芯片KT1605/KT1606/KT1607/KT1608适用对讲机方案
MySQL personal learning summary
Best practice of cloud migration in education industry: Haiyun Jiexun uses hypermotion cloud migration products to implement progressive migration for a university in Beijing, with a success rate of 1
Differences between MySQL BTREE index and hash index
Loggie source code analysis source file module backbone analysis
Nacos 详解,有点东西
Sail soft segmentation solution: take only one character (required field) of a string
ACL 2022 | DialogVED:用于对话回复生成的预训练隐变量编码-解码模型
04 Lua operator
ESXi封装网卡驱动
DanceNN:字节自研千亿级规模文件元数据存储系统概述
Zhongang Mining: Fluorite Flotation Process
05 Lua control structure
Change the icon size of PLSQL toolbar
Creation of RAID disk array and RAID5
100 deep learning cases | day 41 - convolutional neural network (CNN): urbansound 8K audio classification (speech recognition)
MySQL master-slave synchronization pit avoidance version tutorial
最详细的背包问题!!!
JMeter installation tutorial and solutions to the problems I encountered