The Component help you controlAlibaba Cloud CDN,help youDeploy Cdn Domain(add/update)、Start Cdn Domain、Stop Cdn Domain、Refreshes files on Alibaba Cloud CDN edge nodes、Prefetches content from origin servers to L2 CDN edge nodes。
Add or update Cdn Domain,API ReferenceAdd、Get。
Output:
cdn-service:
cdnType: web
domainName: cdn.xxx.xyz
status: online
cname: cdn.fitzdev.xyz.w.kunlunaq.com
sources:
-
content: xxx-vue3.vue-service.xxx.cn-shenzhen.fc.devsapp.net
port: 80
priority: 20
type: fc_domain
weight: 10
refreshConfig:
objectPaths:
- http://cdn.xxx.xyz/
objectType: Directory
Refreshes files on Alibaba Cloud CDN edge nodes。If you want to prefetches content from origin servers to L2 CDN edge nodes after that,you can usewarmUpafter refresh。
Refresh quota
- By default, each Alibaba Cloud account can refresh content from up to 10,000 URLs and 100 directories per day. The directories include subdirectories. If the daily peak bandwidth of your Alibaba Cloud account exceeds 200 Mbit/s, you can submit a ticket to request a quota increase. Alibaba Cloud reviews your request and then increases the quota based on your request.
- By default, each Alibaba Cloud account can submit up to 20 refresh rules that contain regular expressions per day. If the daily peak bandwidth of your Alibaba Cloud account exceeds 10 Gbit/s, you can submit a ticket to request a quota increase.
- You can specify up to 1,000 URL refresh rules, 100 directory refresh rules, or 1 refresh rule that contains regular expressions in each call.
- You can refresh up to 1,000 URLs per minute for each domain name.
Prefetches content from origin servers to L2 CDN edge nodes。
- Each Alibaba Cloud account can submit at most 1,000 URLs per day. If your daily peak bandwidth exceeds 200 Mbit/s, you can submit a ticket to increase the upper limit. Alibaba Cloud will review your application and then increase the quota accordingly.
- Each Alibaba Cloud account can submit up to 100 URLs at a time.
- For each Alibaba Cloud account, the prefetch queue can contain up to 50,000 URLs. Content is prefetched based on the time when the URLs are submitted. The URL that is submitted the earliest has the highest priority. If the number of URLs in the queue reaches 50,000, you cannot submit more URLs until the number drops below 50,000.
- The time required for a prefetch task to complete is proportional to the size of the prefetched file. In actual practice, most prefetch tasks take 5 to 30 minutes to complete. A task with a smaller average file size takes less time.
- You can call this operation up to 50 times per second per account.
Removes a domain name from Alibaba Cloud CDN. Output:
cdn-service:
cdnType: web
domainName: cdn.xxx.xyz
status: online
cname: cdn.fitzdev.xyz.w.kunlunaq.com
sources:
-
content: xxx-vue3.vue-service.xxx.cn-shenzhen.fc.devsapp.net
port: 80
priority: 20
type: fc_domain
weight: 10
edition: 1.0.0
name: component-test # project name
access: default
services:
component-test:
component: devsapp/cdn
props:
cdnType: web # The workload type of the domain name(required),Valid values:web(images and small files)、download(large files)、video(on-demand video and audio streaming)
domainName: xxx.xyz # The domain names that you want to add to Alibaba Cloud CDN(required),Wildcard domain names are supported.A wildcard domain name must start with a period (.), such as .example.com.
sources: # The information about the origin address.(required)
-
type: oss # The type of the origin server(required),Valid values:ipaddr(The origin server uses an IP address)、domain(The origin server uses a domain name)、oss(The origin server is an Object Storage Service (OSS) bucket)、fc_domain( The origin server uses a Function Compute domain name)
content: xxx-html.oss-cn-hangzhou.aliyuncs.com # The address of the origin server. You can specify an IP address or a domain name(required)
prot: 80 # port You can specify port 443, port 80, or a custom port. Default value: 80. If you specify port 443, Alibaba Cloud CDN communicates with the origin server over HTTPS.
priority: 20 # The priority of the origin server if multiple origin servers are specified(not required),Valid values: 20 and 30. Default value: 20. A value of 20 specifies that the origin server is the primary origin server. A value of 30 specifies that the origin server is a secondary origin server.
weight: 10 # The weight of the origin server if multiple origin servers are specified(not required),You must specify a value that is smaller than 100. Default value: 10.
checkUrl: # The URL that is used for health checks.
scope: domestic # The accelerated region(required), Valid values: domestic(regions in mainland China)、overseas(regions outside mainland China.)、global(regions inside and outside mainland China),Default value: domestic.
topLevelDomain: # The top-level domain name
refreshConfig: # The configuration about refreshes files on Alibaba Cloud CDN edge nodes(required when using refresh command)
objectPaths: # The URLs from which content is refreshed (required)
- http://xxx.xyz/
objectType: Directory # The type of the object that you want to refresh,Valid values: File(refreshes one or more files)、Directory(refreshes the files in one or more directories)、Regex(refreshes content based on regular expressions)
pushObjectCacheConfig: # The configuration about prefetches content from origin servers to L2 CDN edge nodes(required when using warmUp command)
objectPaths: # The URLs based on which content is prefetched,must start with http:// or https://,不能重复。
- http://xxx.xyz/a.html
area: # The accelerated region where content is to be prefetched,Valid values:domestic (Mainland China Only)、overseas (Global (Excluding Mainland China))。If you do not set this parameter, content in the accelerated region of the domain name is prefetched。
l2Preload: # Specifies whether to prefetch content to POPs,Valid values: true(prefetch content to L2 edge nodes)。false(prefetch content to regular edge nodes. Regular edge nodes can be L2 edge nodes or L3 edge nodes),Default value: false。
waitUntilFinished: true
maxWaitMs: 120000
refreshAfterDeploy: true
autoOpen: true
autoCreate: true
autoStart: true
Parameter | Type | Required | Description |
---|---|---|---|
cdnType | String | Yes | The workload type of the domain name. Valid values: - web:images and small files。 - download:large files。 - video:on-demand video and audio streaming。 |
domainName | String | Yes | The domain names that you want to add to Alibaba Cloud CDN。 Wildcard domain names are supported.A wildcard domain name must start with a period (.), such as .example.com。 |
sources | Array<Source> | Yes | The information about the origin address。 |
checkUrl | String | Yes | The URL that is used for health checks。 |
scope | String | Yes | The accelerated region。Valid values: - domestic(default value):regions in mainland China。 - overseas:regions outside mainland China.。 - global:regions inside and outside mainland China。 |
topLevelDomain | String | No | The top-level domain name。 |
refreshConfig | RefreshConfig | required when using refresh command | The configuration about refreshes files on Alibaba Cloud CDN edge nodes |
pushObjectCacheConfig | pushObjectCacheConfig | required warmUp using refresh command | The configuration about prefetches content from origin servers to L2 CDN edge nodes |
waitUntilFinished | Boolean | No | wait until the options finish,default value: true |
maxWaitMs | number | No | The longest wait time,work with waitUntilFinished,by default the component will wait 7 minutes |
refreshAfterDeploy | Boolean | No | auto refreshes files on Alibaba Cloud CDN edge nodes after deploy,default value: true |
autoOpen | Boolean | No | auto activates Alibaba Cloud CDN when it was not activated,default value: true |
autoCreate | Boolean | No | add the Cdn Domain when you are starting a not existed Cdn Domain,default value: true |
autoStart | Boolean | No | start the Cdn Domain when your are using the deploy command to update the Cdn Domain,default value: true |
Parameter | Type | Required | Description |
---|---|---|---|
type | String | Yes | The type of the origin server。Valid values: ipaddr:The origin server uses an IP address。 domain:The origin server uses a domain name。 oss:The origin server is an Object Storage Service (OSS) bucket。 fc_domain:The origin server uses a Function Compute domain name。 |
content | String | Yes | The address of the origin server. You can specify an IP address or a domain name. |
port | Integer | No | The port that redirects requests to the origin server.You can specify port 443, port 80, or a custom port. Default value: 80. If you specify port 443, Alibaba Cloud CDN communicates with the origin server over HTTPS. |
priority | String | No | The priority of the origin server if multiple origin servers are specified。Valid values: 20 and 30. Default value: 20。 A value of 20 specifies that the origin server is the primary origin server. A value of 30 specifies that the origin server is a secondary origin server。 |
weight | String | No | The weight of the origin server if multiple origin servers are specified. You must specify a value that is smaller than 100. Default value: 10。 |
Parameter | Type | Required | Description |
---|---|---|---|
objectPaths | Array<String> |
Yes | The URLs from which content is refreshed |
objectType | String | No | The type of the object that you want to refresh。Valid values: - File(default value):refreshes one or more files。 - Directory:refreshes the files in one or more directories。 - Regex:refreshes content based on regular expressions。 If you set the ObjectType parameter to File or Directory, you can view Refresh and prefetch resources to obtain more information. If you set the ObjectType parameter to Regex, you can view Configure URL refresh rules that contain regular expressions to obtain more information.If you set the ObjectType parameter to Directory, the resources in the directory that you want to refresh are marked as expired. You cannot delete the directory. If clients request resources on POPs that are marked as expired, Alibaba Cloud CDN checks whether the resources on your origin server are updated. If resources are updated, Alibaba Cloud CDN retrieves the most recent version of the resources and returns the resources to the clients. Otherwise, the origin server returns the 304 status code. |
Tips: if refreshAfterDeploy was true and refreshConfig was not be setted, the component will refresh the files about the domainName on Alibaba Cloud CDN edge nodes
Parameter | Type | Required | Description |
---|---|---|---|
objectPaths | Array<String> |
Yes | The URLs based on which content is prefetched. Format: accelerated domain name/files to be prefetched。 |
area | String | No | The accelerated region where content is to be prefetched。 Valid values: - domestic:Mainland China Only。 - overseas:Global (Excluding Mainland China)。 If you do not set this parameter, content in the accelerated region of the domain name is prefetched. Content is prefetched based on the following rules: - If the accelerated region is set to Mainland China Only, content in regions in the Chinese mainland is prefetched. - If the accelerated region is set to Global, content in all regions is prefetched. - If the accelerated region is set to Global (Excluding Mainland China), content in regions outside the Chinese mainland is prefetched. |
L2Preload | Boolean | No | Specifies whether to prefetch content to POPs. Valid values: - true: prefetch content to L2 edge nodes. - false: prefetch content to regular edge nodes. Regular edge nodes can be L2 edge nodes or L3 edge nodes. Default value: false. |
The CDN component of Serverless Devs complies with the MIT License.
All files located in the node_modules directories and external directories are from external maintenance libraries that have their own licenses. We recommend that you read the licenses because their terms may be different from the terms of the MIT License.
We welcome your feedback and suggestions. For more information, visit Serverless Devs issues or CDN component issues. If you want to join our discussion group or learn about the latest updates in the CDN component, scan one of the following quick response (QR) codes.
WeChat official account:serverless |
WeChat friend:xiaojiangwh |
DingTalk Froup:33947367 |