当前位置:网站首页>HTTP缓存<强缓存与协商缓存>
HTTP缓存<强缓存与协商缓存>
2022-06-12 17:58:00 【走出自闭的鸟儿】
HTTP缓存
HTTP缓存的基本运作方式

- 浏览器查看自己有没有缓存,如果没有就向服务器索取
- 浏览器自己如果有,就要查看缓存是否过期
- 如果没有过期就使用,过期就向服务器进行验证
- 服务器告知没有过期就能继续使用,服务器告知已经过期就获取新的
总的来说:浏览器先看有无,再看浏览器自己是否过期,再向服务器看是否过期
强缓存
服务器通过响应头传来Catch-Control,设置了资源的过期时间
1. public 这些资源可以被任意对象缓存(如:客户端,代理服务器,等等)
2. private 这些资源只能在客户端缓存
3. max-age=xx 设置资源缓存的最大时间,超过时间表示缓存过期,请求会发到服务器(单位:秒)
4. no-cache 加载缓存资源前,强制发送请求到服务器进行“协商缓存”
5. no-store 不被做任何缓存
协商缓存
服务器返回资源和资源标识,客户端后续发送请求时,向服务器发送请求和资源标识,如果不是最新资源,服务器返回200、最新资源和最新资源标识;如果是最新资源,则服务器返回304,直接从缓存中拿资源。
资源标识:
- Last-Modified:资源上一次修改的时间(了解)
- ETag:资源对应唯一字符串
ETag:在客户端发起的请求,请求头会带有if-none-match,值为上一次响应的ETag,服务器将会对ETag进行对比,相同返回304,从本地缓存拿即可。
区别
二者主要的区别即为:强缓存不会向服务器发起请求,协商缓存则会
边栏推荐
- 有关cookie的用法介绍
- Lightweight and convenient small program to app technology solution to realize interconnection with wechat / traffic app
- SSM integrates FreeMarker and common syntax
- Deep interest evolution network for click through rate prediction
- The server time zone value ‘�й���ʱ��‘ is unrecognized or represents more than one time zone. ......
- Overall flow chart of kernel interrupt
- Reconstruction -- sort out and decompose the inheritance system
- High speed layout guidelines incomplete
- MySQL learning notes
- New media operation material website sharing enables you to create current affairs with half the effort
猜你喜欢

1.5 what is an architect (serialization)
![Vulnhub[DC3]](/img/3a/1aa03e804d447d38e85807928fdb8f.png)
Vulnhub[DC3]
![Vulnhub[DC3]](/img/3a/1aa03e804d447d38e85807928fdb8f.png)
Vulnhub[DC3]

Explanation of core interrupt of Godson processor

Vant3+ts dropdownmenu drop-down menu, multi data can be scrolled

ESP32-C3 ESP-IDF 配置smartconfig 和 sntp 获取网络时间

NixOS 22.05安装过程记录

App中快速复用微信登录授权的一种方法

Advanced mountain -asp Net core router basic use demo 0.1

The server time zone value ‘�й���ʱ��‘ is unrecognized or represents more than one time zone. ......
随机推荐
利用小程序快速生成App,只需七步
error接口原创
Risc-v ide mounriver studio v1.60 update point introduction
Figma从入门到放弃
[CSP]202012-2期末预测之最佳阈值
Esp-idf adds its own components
ftrace
Cesium parabolic equation
AlibabaProtect. How to delete and uninstall exe
566. 重塑矩阵
USB转串口那些事儿—串口驱动类型
grpc-swift入门
Soringboot下RestTemplateConfig 配置打印请求响应日志
Nixos 22.05 installation process record
leetcode491 递增子序列
Reconstruction -- sort out and decompose the inheritance system
C#操作数据库增查业务数据值内容案例学校表
Error record: illegalstateexception: optional int parameter 'XXXX' is
Introduction to cookie usage
566. reshaping the matrix