tencent cloud

Tencent Cloud EdgeOne

Release Notes and Announcements
Release Notes
Security Announcement
Announcements
Product Introduction
Overview
Strengths
Use Cases
Comparison Between EdgeOne and CDN Products
Use Limits
Purchase Guide
Description of Trial Plan Experience Benefits
Free Plan Guide
Billing Overview
Billing Items
Subscriptions
Renewals
Instructions for overdue and refunds
Comparison of EdgeOne Plans
About "clean traffic" billing instructions
DDoS Protection Capacity Description
Getting Started
Choose business scenario
Quick access to website security acceleration
Quick deploying a website with Pages
Domain Service&Origin Configuration
Domain Service
HTTPS Certificate
Origin Configuration
Site Acceleration
Overview
Access Control
Smart Acceleration
Cache Configuration
File Optimization
Network Optimization
URL Rewrite
Modifying Header
Modify the response content
Rule Engine
Image&Video Processing
Speed limit for single connection download
DDoS & Web Protection
Overview
DDoS Protection
Web Protection
Bot Management
API Discovery(Beta)
Edge Functions
Overview
Getting Started
Operation Guide
Runtime APIs
Sample Functions
Best Practices
Pages
L4 Proxy
Overview
Creating an L4 Proxy Instance
Modifying an L4 Proxy Instance
Disabling or Deleting an L4 Proxy Instance
Batch Configuring Forwarding Rules
Obtaining Real Client IPs
Data Analysis&Log Service
Log Service
Data Analysis
Alarm Service
Site and Billing Management
Billing Management
Site Management
Version Management
General Policy
General Reference
Configuration Syntax
Request and Response Actions
Country/region and Corresponding Codes
Terraform
Overview
Installing and Configuring Terraform
Practical Tutorial
Automatic Warm-up/Cache Purge
Resource Abuse/hotlinking Protection Practical
HTTPS Related Practices
Acceleration Optimization
Scheduling Traffic
Data Analysis and Alerting
Log Platform Integration Practices
Configuring Origin Servers for Cloud Object Storage (Such As COS)
CORS Response Configuration
API Documentation
History
Introduction
API Category
Making API Requests
Site APIs
Acceleration Domain Management APIs
Site Acceleration Configuration APIs
Edge Function APIs
Alias Domain APIs
Security Configuration APIs
Layer 4 Application Proxy APIs
Content Management APIs
Data Analysis APIs
Log Service APIs
Billing APIs
Certificate APIs
Origin Protection APIs
Load Balancing APIs
Diagnostic Tool APIs
Custom Response Page APIs
API Security APIs
DNS Record APIs
Content Identifier APIs
Legacy APIs
Ownership APIs
Image and Video Processing APIs
Multi-Channel Security Gateway APIs
Version Management APIs
Data Types
Error Codes
FAQs
Product Features FAQs
DNS Record FAQs
Domain Configuration FAQs
Site Acceleration FAQs
Data and Log FAQs
Security Protection-related Queries
Origin Configuration FAQs
Troubleshooting
Reference for Abnormal Status Codes
Troubleshooting Guide for EdgeOne 4XX/5XX Status Codes
520/524 Status Code Troubleshooting Guide
521/522 Status Code Troubleshooting Guide
Tool Guide
Agreements
Service Level Agreement
Origin Protection Enablement Conditions of Use
TEO Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

EdgeOne + COS Realizes Automatic Cache Purge

PDF
Focus Mode
Font Size
Last updated: 2025-01-24 16:33:19
This document mainly describes how to automatically purge the cache of EdgeOne by using Tencent Cloud Cloud Object Storage (COS) and Serverless Cloud Function (SCF). For the feature and principle of cache purge, refer to Cache Purge.


Background

If your origin server is a Tencent Cloud COS server, when there is an update of files with the same name or non-compliant resources requiring deletion on the origin server, it is usually necessary to also delete the resources from the EdgeOne node to avoid users still accessing old resources or non-compliant contents. However, cache purging requires you to manually go to the EdgeOne console or call the API interface to submit the URL requiring cache purge after you update or delete files on COS. This method can easily lead to omissions and may delay the completion of the purge due to manual operation.

After files are uploaded to Tencent Cloud COS, automatic cache purge can use Tencent Cloud SCF to help you automatically detect and call EdgeOne's cache purge API interface to automatically purge the node cache. This ensures that after your files are updated or deleted, users can immediately access the latest resources, thus enhancing user experience.
Note:
Tencent Cloud COS is a paid feature. Any possible fee incurred in use will be charged by Tencent Cloud COS. For specific charging details, refer to Overview of COS Billing.
SCF is a paid feature. Any possible fee incurred in use will be charged by SCF. For specific charging details, refer to Overview of SCF Billing.

Scenarios

Scenario 1: Updating a file with the same name
After a file is uploaded to Tencent Cloud COS and the file content is updated, re-uploading a file with the same name to COS will immediately make the latest resources accessible to users even before the CDN cache expires.
Scenario 2: Deleting a non-compliant file
A file uploaded to COS may certain a non-compliant content and need to be deleted from the COS bucket so that users cannot access the resource before the CDN cache expires.

Directions

Sample Scenario

Assume you are a game developer and have connected the site domain name www.example.com to EdgeOne Acceleration, with the origin server being Tencent Cloud COS and located at: purge-cos-1251558888.cos.ap-guangzhou.myqcloud.com. Since multiple game APKs need frequent updates, you want the cache on the EdgeOne node to be automatically purged when files change.

Preparations

1. COS and SCF have been activated, and the bucket name and region information are recorded.
2. A site is added according to the Site Access guide, the EdgeOne package is purchased, and the site ID is obtained. The site ID can be viewed and copied in the site list after site access. For example: zone-26v607hq8d3m.

3. Addition of Acceleration Domain Namewww.example.com has been completed at the EdgeOne console, and the origin server is configured to Tencent Cloud COS.

Step 1: Create and Deploy an SCF for Automatic Cache Purge on EdgeOne

1. Log in to the SCF Service console. In the left menu bar, click Function Services.
2. On the Function Services page, click Create, select Template, enter EdgeOneAutomaticallyPurge in the fuzzy search input box, select it, and click Next.

3. On the "Function Configuration" page, the following configurations are required. It is recommended to keep the default values for other configuration items.
Basic configuration
Function name: A function name will be automatically generated when the function is created. You can choose to change it to an easily recognizable function name.
Region: Select the region where the COS bucket is located. For example: Guangzhou.
Time zone: SCF uses UTC time by default. You can change it by configuring the TZ environment variable. After selecting a time zone, the corresponding TZ environment variable will be added automatically.
Function code: The template already includes default function code to implement EdgeOne automatic cache purge, without any modification.
Advanced configuration:
Click Advanced Configuration, find Environment Configuration, and add the following keys and corresponding values to the environment variables. Keep the rest of the configurations as default:
ZoneId: Enter the ZoneId of the domain name site example.com where automatic cache purge is required. Refer to Preparations for how to obtain the site ID.
eoDomains: Enter the acceleration domain name added under ZoneId, such as: www.example.com.

Note:
If origin servers of multiple domain names within the same site use the same COS bucket and you expect multiple domains to trigger automatic cache purge, you can add multiple environment variables starting with eoDomains when configuring the environment. For example: eoDomains_1, eoDomains_2, as shown below:

Permission configuration: Check Enable for the execution role. Select an execution role from the drop-down box (ensure the existing role includes the QcloudCOSFullAccess and QcloudTEOFullAccess preset policies). Otherwise, Create execution role.

Trigger configurations
Take the all creation events event type as an example (if you need to create the all deletion events event type, refer to the configuration). In the trigger configurations, choose Custom. The COS Bucket should be in the same region as this SCF. You can input the bucket name for fuzzy search. For example: purge-cos-1251558888.cos.ap-guangzhou.myqcloud.com. Keep other configuration items as default.

4. Click Finish to finish creating the EdgeOne automatic cache purge function.

Step 2: Verify the Result

1. Log in to the COS console. In the left menu, click Bucket List.
2. On the Bucket List page, click the Bucket Name used for storing APK base packages.
3. On the File List page, go to the root directory of purge-cos-1251558888.cos.ap-guangzhou.myqcloud.com.
4. Click Upload Files, choose a file with the same name, such as: v2_src.apk, and then click Upload.

5. After the file is uploaded successfully, go to the SCF console, and click the Function Name in Step 1.
6. On the Function Management page, select Log Query > Invocation Logs to get the log information of the function execution. If the invocation is successful and the key information in the log matches the name of the uploaded file, it means that the file upload to COS has triggered the SCF to call the EdgeOne cache purge API successfully.

7. Go to the EdgeOne console. In the primary navigation bar, click Toolset and then click Purge Cache.
8. In the Purge Cache page, click History to check whether the cache purge task succeeded. If it shows that the task succeeded, it means the cache has been purged.

9. After opening the Developer Tools in the browser, enter the access path of the file, such as: www.example.com/v2_src.apk. Check the EO-Cache-Status value in the response header. If the cache is not purged, the old cache will be hit when the resource is accessed. As shown in the image below, if MISS is displayed, it means the resource has been cleared from the EdgeOne node, and the user request will pull the latest resource from the origin.


Monitoring Alarm (Recommendation)

EdgeOne sets quota limits for Cache Purge tasks. For specific quotas, refer to Comparison of EdgeOne Plans.
For Cache Purge tasks that exceed the quota limit, an error will be triggered when calling the Cache Purge cache API, and the final execution status of the SCF will be "calling failure". To promptly address this issue, it is recommended to configure SCF monitoring alarms through Cloud Monitor. For configuration methods, refer to: Configuring SCF Alarms, SCF Metric Descriptions.



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback