当前位置:网站首页>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 .
边栏推荐
- Funny! Pictures and texts give you a comprehensive understanding of the effects of dynamics and mass
- Abnormal dockgeddon causes CPU 100%
- A survey of training on graphs: taxonomy, methods, and Applications
- How to select an open source license
- AI video structured intelligent security platform easycvr realizes intelligent security monitoring scheme for procuratorate building
- The mystery of redis data migration capacity
- Fastjson vulnerability utilization techniques
- How FEA and FEM work together
- How do HPE servers make RAID5 arrays? Teach you step by step today!
- How to pop up an alarm through the national standard gb28181 protocol video platform easygbs for mobile detection / perimeter intrusion detection video recording
猜你喜欢

Problems encountered in the work of product manager
Advanced programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization

Ps\ai and other design software pondering notes

ZOJ——4104 Sequence in the Pocket(思维问题)

C. K-th not divisible by n (Mathematics + thinking) codeforces round 640 (Div. 4)

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

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

C. K-th Not Divisible by n(数学+思维) Codeforces Round #640 (Div. 4)

Ui- first lesson

A survey on model compression for natural language processing (NLP model compression overview)
随机推荐
Fastjson 漏洞利用技巧
What is the difference between get and post? After reading it, you won't be confused and forced, and you won't have to fight with your friends anymore
MySQL Innodb和Myisam
Little red book, hovering on the edge of listing
Pytorch 转置卷积
Is Guotai Junan Futures safe? How to open a futures account? How to reduce the futures commission?
Global and Chinese market of music synthesizer 2022-2028: Research Report on technology, participants, trends, market size and share
SQL multi table updating data is very slow
A memory leak caused by timeout scheduling of context and goroutine implementation
MySQL日期时间戳转换
A troubleshooting of golang memory leak
Finite element simulation in design
Dismantle the industrial chain of synthetic rubber industry, and the supply chain may become a sharp weapon for breakthrough
#夏日挑战赛# HarmonyOS - 实现带日期效果的待办事项
Is Shanjin futures safe? What are the procedures for opening futures accounts? How to reduce the futures commission?
B. Ternary Sequence(思维+贪心)Codeforces Round #665 (Div. 2)
A set of very good H3C and Tianrongxin Internet cutover scheme templates, with word document download
C. Three displays(动态规划)Codeforces Round #485 (Div. 2)
Don't let [mana] destroy your code!
【prometheus】1. Monitoring overview