Alibaba Cloud CDN is seamlessly integrated with Function Compute. You can write function code to perform custom operations on Alibaba Cloud CDN events. You can configure an Alibaba Cloud CDN event trigger to trigger a function when Alibaba Cloud CDN receives a specific event that meets the filtering conditions.
Background information
Alibaba Cloud CDN is a distributed network that is built on top of the bearer network and consists of edge server clusters that are distributed in different regions. You can replace the conventional web server-based data transmission mode by using Alibaba Cloud CDN to cache resources of origin servers to edge servers that are distributed in different regions. Caching of resources allows you to obtain data from the nearest servers. This improves user experience and reduces workloads on the origin server. In Function Compute, you can configure Alibaba Cloud CDN event triggers to integrate Function Compute with Alibaba Cloud CDN and perform custom operations on Alibaba Cloud CDN events. For example, you can configure a function and an Alibaba Cloud CDN event trigger to process resource refresh events in the www.taobao.com domain. When a resource refresh event occurs in the domain, the Alibaba Cloud CDN event trigger automatically executes the function.
Scenarios
An Alibaba Cloud CDN event trigger can integrate Function Compute and Alibaba Cloud CDN in the following scenarios:
If user data is preloaded and refreshed in Alibaba Cloud CDN, CachedObjectsPushed and CachedObjectsRefreshed events occur. The associated function is automatically triggered. In this case, you can obtain the preload and refresh status of resources before you proceed to the next step, which prevents constant list polling for the most recent status.
If a log file is generated, a LogFileCreated event occurs. The associated function is automatically triggered to process logs with high efficiency, without waiting for a long period of time.
If an accelerated domain name is enabled or disabled, a CdnDomainStarted or CdnDomainStopped event occurs. The associated function is automatically triggered to process data at the earliest opportunity.
Alibaba Cloud CDN events
When Alibaba Cloud CDN captures specific events, the system encodes the events in JSON strings and forwards the events to the associated functions for processing. The following table lists the events and versions that are supported by Alibaba Cloud CDN event triggers.
Event | Version | Filter parameter | Reference |
CachedObjectsRefreshed | 1.0.0 | domain | |
CachedObjectsBlocked | 1.0.0 | domain | Encapsulates a specified URL on a point of presence (POP). Note If you want to use this operation, submit a ticket to have your account added to the whitelist of Alibaba Cloud CDN. |
CachedObjectsPushed | 1.0.0 | domain | |
LogFileCreated | 1.0.0 | domain | |
CdnDomainStarted | 1.0.0 | domain | |
CdnDomainStopped | 1.0.0 | domain | |
CdnDomainAdded | 1.0.0 | domain | |
CdnDomainDeleted | 1.0.0 | domain |