当前位置:网站首页>Automatically refresh CDN cache in real time based on cos log
Automatically refresh CDN cache in real time based on cos log
2022-06-24 16:36:00 【tinkerli】
Problem scenario
background : Many companies now use object storage services to store static files / Pictures, etc , Make full use of cloud functions to realize data processing ( Data Vientiane ), Such as COS Zoom in / Cutting and other functions ; At the same time through CDN The ability to accelerate , Improve access quality .
problem : File deletion , Possible complaints from third parties ; It may come from the violation ; It may come from the company's own business needs, etc ;COS File deletion ,CDN Cache refresh required ; If data processing capability is used , Like Vientiane , May produce the same key, Several URL, Need to refresh the cache .
solve :
single key- single path scene , Such as key by /aaa/bbb.jpg, The only cache deleted is /aaa/bbb.jpg Scene , At present Function calculation Function automatic refresh function ;
single key- Scenes with parameters or styles , Such as key by /aaa/bbb.jpg, Deleted cache URL May be /aaa/bbb.jpg, It could be /aaa/bbb.jpg?aaaa=1233&a=b, It could be /aaa/bbb.jpg/yangshi, At present, this scenario has not been covered by function calculation , Need to pass through COS The real-time log of is CLS The log service To automatically implement the refresh function , It also supports the coverage of the first scenario .
Architecture Topology
Implementation process
Prerequisite :
- First open the corresponding cos bucket Log retrieval function of
- Get the corresponding log set and log topic information
- Get account number API Key information
- obtain CLS Public domain name information corresponding to different regions
Create function services
Basic configuration and function code :
- How it was created : choice " Custom creation "
- Function name : Customize it , such as refresh_cdn_cache
- regional : Need and cos bucket In the same region
- Running environment : choice "python3.6"
- function code : choice " Upload locally zip package "
Local zip Please use the attachment of this article for the package :
Advanced configuration - Environment configuration :
cls_day_num=7 # The cycle of retrieving logs cls_domain=ap-shanghai.cls.tencentcs.com # Corresponding area cls The public domain name of the log service cos_bucket_name=tinkerli-cls-1251956900 # Corresponding cos bucket Name hosts=cls-cos.xxxxxxx.cn # Corresponding to those that need to be clearly cached CDN domain name , Support multiple , With ';' Division logset_id=49fc1a43-a340-49c8-91be-fcb4abd106a4 # Corresponding log set id secret_id=AxxxxD7nxxxxxxxxxxLDsiN7B8p # Corresponding API secret key id secret_key=d1AHFJDtdDLjxxxxxxxx # Corresponding API secret key key topic_ids=0b82160f-9c46-4b95-a668-63874b5cf37f # Corresponding log topics id
Trigger configuration :
- Trigger mode : choice COS Trigger
- Event type : Select delete file
functional verification
COS File deletion :
- Both batch deletion and single file deletion are allowed , Such as through cos Console batch delete
see SCF Run log :
- You can see batch deletion 3 File , Triggered three cloud function calls , All successful .
verification CDN Brush result :
- To CDN In the console - View the refresh results
You can see each URL Both are refreshed successfully , Whether styled or spliced URL Of
Additional explanation
- Tencent cloud The log service Tencent cloud has gradually supported various cloud product log access , Such as CLB,CDN,COS,TKE And so on ;
- COS Delete files in bulk , The delete event of multiple files will be triggered ;
- This article is only aimed at the problem solving of one scenario , More log based games are welcome .
边栏推荐
- [go] concurrent programming channel
- Global and Chinese markets of natural insect repellents 2022-2028: Research Report on technology, participants, trends, market size and share
- The mystery of redis data migration capacity
- Tencent releases the full platform version of reasoning framework TNN, and supports mobile terminal, desktop terminal and server terminal at the same time
- Virtual machine virtual disk recovery case tutorial
- Abnormal dockgeddon causes CPU 100%
- Product level design of a project in SAP mm
- 期货怎么开户安全些?哪些期货公司靠谱些?
- Serial of H3CNE experiment column - spanning tree STP configuration experiment
- Load MySQL table data consumption quick installation configuration through kafka/flink
猜你喜欢

B. Terry sequence (thinking + greed) codeforces round 665 (Div. 2)

Ps\ai and other design software pondering notes

A survey on model compression for natural language processing (NLP model compression overview)

B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)

C. Three displays(动态规划)Codeforces Round #485 (Div. 2)

C. Three displays codeforces round 485 (Div. 2)

ZOJ - 4104 sequence in the pocket

A survey on dynamic neural networks for natural language processing, University of California
![[go] concurrent programming channel](/img/6a/d62678467bbc6dfb6a50ae42bacc96.jpg)
[go] concurrent programming channel

Applet wxss
随机推荐
Kubernetes popular series: getting started with container Foundation
Web page live broadcast on demand RTMP streaming platform easydss newly added virtual live broadcast support dash streaming function
A survey on dynamic neural networks for natural language processing, University of California
Pageadmin CMS solution for redundant attachments in website construction
What is a framework?
Heavy release! Tencent cloud ASW workflow, visual orchestration cloud service
Cause analysis of the failure of web page live broadcast on demand RTMP streaming platform easydss streaming live broadcast
B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)
What is cloud development? Why cloud development? Talk about our story
Where is the most formal and safe account opening for speculation futures? How to open a futures account?
If only 2 people are recruited, can the enterprise do a good job in content risk control?
06. Tencent cloud IOT device side learning - Introduction to basic functions
Greenplum role-based fine-grained permission control
Several characteristics of pharmaceutical industry
ZOJ - 4104 sequence in the pocket
Object store signature generation
转置卷积学习笔记
Bitwise Operators
Kubernetes characteristic research: sidecar containers
Interpretation of swin transformer source code