当前位置:网站首页>Node cache vs browser cache
Node cache vs browser cache
2022-06-24 12:32:00 【mengmye】
background :
CDN Node caching policy :
A reasonable caching policy can be set according to the actual business scenario , For example, follow the origin 、 follow CDN Configured cache time, etc , For different files , Or directory, etc . In cache time ,CDN The node directly caches the response to the client ; If cache expires , User access will trigger the node to go back to the source to verify whether the file is updated . If the file cache has not expired , But the origin site has been updated and wants users to access the new file immediately , The refresh operation can be submitted , Force clear CDN cache , Trigger the pull back to the source .
Browser caching strategy :
Mandatory cache : 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 .
Negotiate the cache : After the forced cache expires , The browser makes a request to the server with the cache id , Generally used if-modified-since/Last-Modified and if-none-match/Etag It is up to the server to decide whether the resources cached by the browser can be used .
In general , Node cache and browser cache are independent , It doesn't affect each other . But Tencent cloud in a specific scenario of a specific platform , The two will be related .
Problem description :
Customer feedback will be domain name vodtest.xiaobli.xyz “ All files are not cached ” After the policy of is deleted , Visit below url file ,CDN Nodes and browsers will cache , Fall short of expectations .
https://vodtest.xiaobli.xyz/nbi/rt/traffic/overview?platform=2&today=2021-03-18
Cause analysis :
1、 Confirm domain name vodtest.xiaobli.xyz Node caching policy for .
As shown below , Customer feedback url No match to any of the rules .
Test verification , Reproduce the phenomenon of caching in the node (Hit From Disktank3 That means cache hit ). And from the response header, you can find :
(1) When node cache misses , nothing Cache-Control: max-age Head ;
(2) When the node cache hits , Yes Cache-Control: max-age Head .
(3) Bind origin test , Source station none Cache-Control Related cache headers .
why CDN The node caches the file ? With this question , Search product documents (https://cloud.tencent.com/document/product/228/47672), Find the answer as follows :
Platform default policy
If you do not configure any rules, or if a request misses a configured rule , The following platform policies are followed by default :
- When a user requests a business resource , If the source station corresponds to HTTP Response Header in Cache-Control Field , Follow this Cache-Control
- If the source station corresponds to HTTP Response Header No middle Cache-Control Field , be :CDN The node caches the resource by default 600s.
Customer feedback url, Missed configured rules , And the source station has no Cache-Control Field , be CDN Nodes cache 600s.
2、 Confirm domain name vodtest.xiaobli.xyz Browser caching policy .
As shown below , The domain name has no browser cache expiration configuration . In this case , How long the browser caches depends on when accessing a resource , The server responds Cache-Control
or Expires. In general, this is 2 All headers are inherited from the source site ,CDN The side is not modified . Customer feedback on this url, The origin station does not have this 2 A head , It should not cache . But because of this file CDN After node caching , Will default to add Cache-Control: max-age=600, That causes the browser to cache .
Solution :
In addition to the file types for which the caching policy is explicitly set , No other files need to be cached , The following scheme can be adopted ( One out of two ).
1、 Based on the current cache policy , Add a new one “ All files are not cached ”( The lowest priority ) The bottom line strategy , Just operate the console .
2、 in the light of CDN There is no file type with explicit cache policy set on the side , The origin station needs to return Cache-Control:no-cache And so on .
边栏推荐
- Cloud native database: the outlet of the database, you can also take off
- Pipeline shared library
- 11+! 结肠癌中基于 m6A 调节因子的甲基化修饰模式以不同的肿瘤微环境免疫谱为特征
- I'm in Shenzhen. Where can I open an account? Is it safe to open an account online now?
- VaR in PHP_ export、print_ r、var_ Differences in dump debugging
- 11+! Methylation modification patterns based on m6A regulatory factors in colon cancer are characterized by different tumor microenvironment immune spectra
- Fbnet/fbnetv2/fbnetv3: Facebook's lightweight network exploration in NAS | lightweight network
- [5 minutes to play lighthouse] create an immersive markdown writing environment
- Ten thousand campus developers play AI in a fancy way. It's enough to see this picture!
- Jenkins pipeline syntax
猜你喜欢
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source
Opencv learning notes -- Separation of color channels and multi-channel mixing
[mysql_16] variables, process control and cursors
QT -- the qtabwidget supports dragging tabbar items
Ten thousand campus developers play AI in a fancy way. It's enough to see this picture!
Database migration tool flyway vs liquibase (II)
我真傻,招了一堆只会“谷歌”的程序员!
[digital ic/fpga] booth multiplier
计组-总复习
GLOG从入门到入门
随机推荐
Difference between X12 830 and 862 messages
最新热点:使用铜死亡相关基因进行肿瘤预后分型!
【Go语言刷题篇】Go从0到入门4:切片的高级用法、初级复习与Map入门学习
GLOG from getting started to getting started
The solution of distributed system: directory, message queue, transaction system and others
2022年有什么低门槛的理财产品?钱不多
Pipeline shared library
Use go to process millions of requests per minute
ArrayList#subList这四个坑,一不小心就中招
What should music website SEO do?
Concentrate on research preparation, Tencent cloud, see you next year!
嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)
Which commercial insurance endowment insurance is good? Ranking of commercial endowment insurance products in 2022
Based on am335x development board arm cortex-a8 -- acontis EtherCAT master station development case
Linker --- linker
Continuous testing | test process improvement: practice continuous testing within iterations in coding
Programmer: after 5 years in a company with comfortable environment, do you want to continue to cook frogs in warm water or change jobs?
Embedded must learn! Detailed explanation of hardware resource interface - based on arm am335x development board (Part 1)
Ingenious conception - iron death regulatory factor classification and prognosis 6+
Is it safe to open an account under the conditions of new bonds