当前位置:网站首页>ASP. NET CORE Study08
ASP. NET CORE Study08
2022-06-28 12:35:00 【When the human stars shine】
Get New knowledge :
cache
Relevant concepts :
The type of cache :
summary :
in general , Private caching reduces the need for network bandwidth , At the same time, it will reduce the cache to API Request . Because the private cache is stored in the client browser , For requests , If the cache is still in a limited period , Then the request will not be sent even the network request, and the response will be directly obtained in the client browser , This reduces the number of network requests , It will also reduce API Number of requests .
Shared caching does not save caching to API Network bandwidth of , But it reduces requests to API Request . Because the shared cache is stored on the server side , The request must reach the server first , This will not reduce network bandwidth , But it will be reduced to API Request , Because subsequent requests are handled by the cache , Not every time API perform .
therefore , In general , Private cache and shared cache should be used together , But caching is more used for static resources , Such as images , Content pages, etc , And for those that change frequently API It's not appropriate , Such as adding or updating , The rest of the clients should get the latest resources , But if it's a cache , The remaining clients can only get the old resource information within the cache period .
This requires validating the model .
Cache usage
Expiration Model :
The expiration model sets how long the response information can be kept “ fresh ” To keep whether the cache is expired , adopt Cache-Control Request headers to set whether the cache expires .
When the expired cache is working ,
The first request will be cached first , But at this time, the cache is empty , So the request goes to API,API Will return the response to the cache , At the same time, the response header will include Cache-Control Response head , Indicate cache lifetime, cache type, etc , The cache will copy the response into the cache , And return the response , Requests for subsequent entry will not enter as long as they are in the fresh period API Inside , Instead, the cache returns the response directly .
Validate the model :
Used to verify whether the cached response data is kept up to date .
When the cached data will become the response of the client request , It first checks the source server or the intermediate cache with the latest data , See if the data it caches is still up to date .
In general :
Cache-Control Commonly used instructions
Cache-Conrtol Respond to common instructions :
Cache-Control Request common instructions :
ETag Use
A third party NuGet package Marvin.Cache.Headers Provides a very complete and powerful Cache management function .
install Marvin.Cache.Headers package , stay startup Of configureservice Register for services , stay configure Method to use the cache middle price . Last , stay controller Go up or action On , Carry out property annotation .
The package provides complete functionality .
concurrency control
Concurrency issues , It can mean Two clients ,1 and 2, Customer 1 Get a resource first , Subsequent customers 2 Also obtained this resource , And customers 2 The update operation is performed and pushed to the server , At this point, the customer 1 Also update the resource , So customers 1 The change will bring the customer 2 Full coverage of , This is concurrency control .
Pessimistic Concurrency
Resources are locked for the previous customer , As long as the resource is locked , No one else can modify it , Only customers 1 You can modify , But this REST Can not be achieved under , because REST There are no state constraints .
Optimistic concurrency control
This means that the customer 1 You'll get one Token, And allow him to update resources , as long as Token Is reasonable and effective , So customers 1 You can always update the resource . stay REST Can be realized in , And this Token It's just a verifier , And it is required to be a strong verifier , So you can use ETag.
Optimistic concurrency control Example 
figure :
边栏推荐
- 为什么CAD导出PDF没有颜色
- It really doesn't matter if a woman fails to pass the college entrance examination and buys thousands of villas in a counter attack
- 2022招商FinTech比赛总结
- AsyncTask经验小结
- [C language] use of nested secondary pointer of structure
- Privilege management of vivo mobile phone
- 企业源代码保密方案分享
- 【Unity编辑器扩展基础】、EditorGUILayout (三)
- URL append parameter method, considering #$ Situation of
- Wechat authorized login
猜你喜欢

EMC RS485接口EMC电路设计方案

10万美元AI竞赛:寻找大模型做得“更烂”的任务

已知两个点和中间一个比例的点,求该点坐标

ASP.NET CORE Study08

ASP. NET CORE Study02

My NVIDIA developer tour -jetson nano 2GB teaches you how to train models (complete model training routines)

易观分析《2022年中国银行业隐私计算平台供应商实力矩阵分析》研究报告正式启动

Given two points and a point with a middle scale, find the coordinates of the point

Beginner level of attack and defense World Hello_ pwn

IPETRONIK数据采集设备携手Softing Q-Vision软件致力于ADAS测试方案
随机推荐
KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"
pwn入门(1)二进制基础
《数字经济全景白皮书》消费金融数字化篇 重磅发布
ASP. NET CORE Study03
Remoteviews layout and type restriction source code analysis
After importing resources, unity also manually modifies the properties of resources? This code can save you a lot of time: assetpostprocessor
最新!基于Open3D的点云处理入门与实战教程
How to get a generic type
ASP. NET CORE Study02
吐血推荐17个提升开发效率的“轮子”
Unity Editor Extension Foundation, guilayout
易观分析《2022年中国银行业隐私计算平台供应商实力矩阵分析》研究报告正式启动
真正的学懂三极管入门篇(经典)「建议收藏」
ASP.NET CORE Study08
【经验分享】Django开发中常用到的数据库操作总结
Beginner level of attack and defense World Hello_ pwn
Namespace and scope
杰理之wif 干扰蓝牙【篇】
Truly understand triode beginner level chapter (Classic) "suggestions collection"
Is tongdaxin stock software reliable? Is it safe to trade stocks on it?