当前位置:网站首页>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 .
边栏推荐
- Examples of AES and RSA encryption operations implemented by php7.1
- Fbnet/fbnetv2/fbnetv3: Facebook's lightweight network exploration in NAS | lightweight network
- Opencv learning notes - Discrete Fourier transform
- Opencv learning notes - regions of interest (ROI) and image blending
- How to check the situation that the national standard platform easygbs equipment video cannot be accessed by grabbing packets?
- How to evaluate software development projects reasonably?
- Is it safe to apply for new bonds to open an account
- Is it safe to open an account for how many new bonds you can apply for
- Clickhouse uses distributed join of pose series
- 2021-06-02: given the head node of a search binary tree, it will be transformed into an ordered two-way linked list with head and tail connected.
猜你喜欢

Axi low power interface

【数字IC/FPGA】Booth乘法器

Install Kali on the U disk and persist it

Basic path test of software test on the function of the previous day

Group planning - General Review

AXI低功耗接口

How to write controller layer code gracefully?
Deep parsing and implementation of redis pub/sub publish subscribe mode message queue

GTEST from getting started to getting started

Linker --- linker
随机推荐
How can a shell script (.Sh file) not automatically close or flash back after execution?
[Old Wei makes machines] issue 090: keyboard? host? Full function keyboard host!
哪个商业保险养老险好?2022年商业养老保险产品排名
广发证券靠谱吗?开证券账户安全吗?
Conceptual analysis of DDD Domain Driven Design
Examples of AES and RSA encryption operations implemented by php7.1
Kubernetes practical skills: use cert manager to issue free certificates for DNSPod domain names
The opportunity to teach cloud development a lesson has finally come!
[Architect (Part 41)] installation of server development and connection to redis database
Ten thousand campus developers play AI in a fancy way. It's enough to see this picture!
What are the low threshold financial products in 2022? Not much money
Which commercial insurance endowment insurance is good? Ranking of commercial endowment insurance products in 2022
Listed JD Logistics: breaking through again
Opencv learning notes - loading and saving images
The idea of "6 points + gene family" without experiment~
【Go语言刷题篇】Go从0到入门4:切片的高级用法、初级复习与Map入门学习
Is it safe to open an account under the conditions of new bonds
OpenGL es shared context for multi-threaded rendering
What is the reason why the video intelligent analysis platform easycvr is locally controllable but the superior equipment cannot control the subordinate equipment?
怎样申请打新债 开户是安全的吗