If your website provides images, text, and on-demand videos, you can use Alibaba Cloud CDN to accelerate content delivery. This topic describes how to accelerate content delivery for infographic and video websites.
Prerequisites
Alibaba Cloud CDN is activated. For information about how to activate Alibaba Cloud CDN, see Activate Alibaba Cloud CDN.
An origin server that provides stable performance is deployed. If you do not have an origin server, follow the instructions in Create and manage an ECS instance in the console (express version) or Create a bucket to create one.
Scenarios
Alice wants to accelerate content delivery for a small-sized community website. Information about the website includes:
Domain name: aliyundoc.com.
Website content: images, text, and on-demand videos.
Acceleration region: Chinese mainland. Visitors to the website are mostly located in the Chinese mainland.
Other services: Image and video files are stored in an Object Storage Service (OSS) bucket. HTTPS secure acceleration is used to encrypt data transmission.
Procedure
The following procedure shows how to use Alibaba Cloud CDN to accelerate content delivery for a website. The preceding scenario is used as an example.
Step 1: Add a domain name
The images and videos provided by the website are of different workload types. Therefore, you must use different domain names to accelerate the delivery of images and videos.
Domain name for image-based services: image.developer.aliyundoc.com
Domain name for video-based services: video.developer.aliyundoc.com
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, click Add Domain Name.
Add a domain name.
On the Add Domain Name page, configure the parameters that are described in the following table. In this example, image.developer.aliyundoc.com is used.
NoteThe first time a domain name is added to Alibaba Cloud CDN, Alibaba Cloud CDN verifies the ownership only of the root domain name. For more information, see Verify the ownership of a domain name. If the root domain name has already passed ownership verification, skip this operation.
Service type
Domain Name to Accelerate
Business Type
Region
Image-based services
image.developer.aliyundoc.com
Image and Small File
Chinese Mainland Only
Video-based services
video.developer.aliyundoc.com
VOD
Chinese Mainland Only
Configure an origin server.
In this example, an OSS bucket is used as the origin server. Requests for resources that are not cached or have expired on points of presence (POPs) are redirected to the OSS bucket. Then, the retrieved resources are cached on POPs.
In the Add Origin Server dialog box, configure the parameters that are described in the following table.
Parameter
Description
Origin Info
Select OSS Domain and then select the OSS bucket in which the resources are stored from the Domain Name drop-down list. OSS buckets that belong to the current Alibaba Cloud account are displayed. You can also enter the public domain name of the OSS bucket, such as xxx.oss-cn-hangzhou.aliyuncs.com. Internal domain names of OSS buckets are not supported. You can view the public domain name of an OSS bucket in the OSS console.
Priority
If you specify only one origin server, you do not need to specify primary or secondary origin servers. You can keep the default settings.
Weight
Port
Click OK.
After you add an origin server, click Next.
Wait for manual verification to complete.
NoteIf the domain name does not need to be manually verified, proceed to the next step. In the next step, you can configure the parameters based on your business requirements.
After the domain name passes the verification, the status of the domain name changes to Enabled. In this case, the domain name is added to Alibaba Cloud CDN.
Repeat the preceding steps to add video.developer.aliyundoc.com to Alibaba Cloud CDN.
Step 2: Configure the domain name
To improve acceleration performance, secure data transmission, and accelerate content delivery, you can enable the corresponding features based on your business requirements.
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
Configure the features based on your business requirements. The following table describes the features.
Scenario
Description
Configuration
Specify the site to which POPs redirect requests
If you set the origin server type to OSS Domain, the Domain Type parameter in Origin Host is automatically set to Origin Domain. In this case, retain the default settings.
If the OSS bucket is mapped to a custom domain name, such as origin.developer.aliyundoc.com, set the Domain Type parameter to Custom Domain, and set the origin host to origin.developer.aliyundoc.com. For more information, see Configure the default origin host. In other cases, you do not need to modify the origin host settings.
Grant Alibaba Cloud CDN access permissions on private OSS buckets
If you set the access control list (ACL) of the OSS bucket to private, you must grant Alibaba Cloud CDN access permissions on the private OSS bucket.
Increase the cache hit ratio
Specify a time to live (TTL) value for cached resources based on the following rules to increase the cache hit ratio:
Specify a TTL of one month or longer for static files that are infrequently updated, such as images and application packages.
Specify a TTL based on your business requirements for static files that are frequently updated, such as JavaScript and CSS files.
Specify a TTL of 0 seconds to disable caching for dynamic files, such as PHP, JSP, and ASP files.
Improve data transmission security
You need to obtain an SSL certificate before you can enable HTTPS. You can use Certificate Management Service to apply for and purchase SSL certificates.
NoteHTTPS secure acceleration is a value-added service. After you enable HTTPS, you are charged based on the number of HTTPS requests. You cannot use data transfer plans to offset the fees. For more information about the pricing of HTTPS secure acceleration, see Billing of value-added services.
Purchase an SSL certificate. For more information, see Purchase an SSL certificate.
Apply for an SSL certificate. For more information, see Submit a certificate application.
Configure an SSL certificate: Set the Certificate Source parameter to SSL Certificates Service.
Protect websites from hotlinking and IP theft
URL signing must work with the origin server because the origin server is required to generate signed URLs based on the authentication algorithm that is specified for the signing type in Alibaba Cloud CDN.
Increase the cache hit ratio
Increase file distribution efficiency
After you enable the parameter filtering feature, POPs generate hash keys while removing the parameters that follow the question mark (
?
).Accelerate resource retrieval
After you enable the range origin fetch feature, the OSS bucket that functions as the origin server returns the file chunk that is specified by the Range header to POPs. This reduces origin traffic and accelerates content delivery.
NoteThe range origin fetch feature is suitable for large file distribution scenarios such as audio and video streaming. Range origin fetch is not suitable for small file distribution scenarios. You do not need to enable the range origin fetch feature when you use Alibaba Cloud CDN to accelerate the delivery of images.
Improve website security
We recommend that you enable security features based on your business requirements to reinforce protection for your website.
You can specify a bandwidth cap to prevent unexpected high bills due to attacks.
Copy the settings.
Copy the settings of image.developer.aliyundoc.com to video.developer.aliyundoc.com.
NoteSkip this step when you configure the first domain name image.developer.aliyundoc.com. You need to copy the settings when you configure video.developer.aliyundoc.com.
On the Domain Names page, find image.developer.aliyundoc.com and click Copy Configurations in the Actions column.
Select the settings that you want to copy and click Next.
Select video.developer.aliyundoc.com and click Next.
In the Copy Configurations dialog box, click OK.
Step 3: (Optional) Test whether the domain name is accessible
After you add the domain name to Alibaba Cloud CDN, we recommend that you test whether the domain name is accessible before you update the CNAME record of the domain name. This ensures that DNS updates do not affect the services of the domain name. For more information, see (Optional) Test whether a domain name is accessible.
Step 4: Add a CNAME record
After you add a domain name to Alibaba Cloud CDN, the system assigns a CNAME to the domain name. You must add a CNAME record to the system of your DNS service provider to map the domain name to the CNAME before requests can be redirected to POPs. Otherwise, CDN acceleration cannot take effect.
Each domain name is assigned a unique CNAME. In the following example, Alibaba Cloud DNS is used to show how to add a CNAME record to the system. For more information, see Add a CNAME record for a domain name.
Domain name | Record Type | Hostname | DNS Request Source | Record Value | TTL |
image.developer.aliyundoc.com | CNAME |
| Default |
| Keep the default setting. |
video.developer.aliyundoc.com | CNAME |
| Default |
| Keep the default setting. |