当前位置:网站首页>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 :
边栏推荐
- Truly understand triode beginner level chapter (Classic) "suggestions collection"
- C语言 sprintf函数使用详解
- Setting overridesorting for canvas does not take effect
- 2022年理财产品的常见模式有哪些?
- Ugui force refresh of layout components
- Unity导入资源后还手动修改资源的属性?这段代码可以给你节约很多时间:AssetPostprocessor
- URL append parameter method, considering #$ Situation of
- 2022-06-28日报:LeCun最新论文:通往自主机器智能的道路
- The paging style flex is set to be displayed at the end (even if the number of pages is longer, there will be no line breaks at the end)
- ASP.NET CORE Study07
猜你喜欢
随机推荐
[unity Editor Extension practice] find all prefabs referencing this picture
IPETRONIK数据采集设备携手Softing Q-Vision软件致力于ADAS测试方案
真正的学懂三极管入门篇(经典)「建议收藏」
Sha256 encryption tool class
UGUI使用小技巧(六)Unity实现字符串竖行显示
Jerry's wif interferes with Bluetooth [chapter]
C语言 sprintf函数使用详解
我的NVIDIA开发者之旅-Jetson Nano 2gb教你怎么训练模型(完整的模型训练套路)
KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"
ASP.NET CORE Study11
Is tongdaxin stock software reliable? Is it safe to trade stocks on it?
Bytev builds a dynamic digital twin network security platform -- helping network security development
请问通达信股票软件可靠吗?在上面交易股票安全吗?
ASP. NET CORE Study01
[source code + code comments] error state Kalman filter, extended Kalman filter, gps+imu fusion, EKF eskf gps+imu
UGUI强制刷新Layout(布局)组件
模板_大整数乘法
What is data compliance? How to achieve data compliance?
How to get a generic type
Enterprise source code confidentiality scheme sharing








