This topic explains how CDN works and describes the key configuration settings. By following the examples, you can quickly and efficiently enable CDN.
In this topic, www.example.com is used as the example domain name that users access, and 10.10.10.1 is used as the IP address of the origin server.
How CDN accelerates content delivery
If you are unfamiliar with how CDN works, you can read this section to learn more. If you already understand how a CDN works, you can skip this section and proceed to configure CDN.
Quickly integrate CDN
A core advantage of CDN is its non-intrusive nature. You do not need to modify any business code. You can simply complete a few configuration steps to quickly accelerate your content. This topic uses two typical scenarios to explain the configuration process and describes each setting to help you get started.
Before you integrate CDN, complete the following two steps:
You must have an Alibaba Cloud account. If you do not have one, you can register on the account registration page. If your acceleration service covers the Chinese mainland, you must also complete account verification.
You must activate CDN in your Alibaba Cloud account.
1. Add a domain name and origin server
Configure the domain name
To accelerate your domain name, you must add it as an Domain Name to Accelerate in the CDN console. Only after this step is complete can CDN recognize and accelerate your domain name.
Verify domain ownership
To ensure that you own the domain name that you want to add, CDN requires you to verify the ownership of the domain name. You can skip this step if you have already completed the verification or if you do not receive a verification prompt when you add the accelerated domain name.
Configure origin server information
The origin server is the server where your business runs. You must configure origin server information in the CDN console. This way, CDN nodes can retrieve resources from your server when the requested resources are not cached on the CDN nodes.
Verify the accelerated domain name
After you add the accelerated domain name, you can test it locally before you update the DNS record to point to the CNAME record. This ensures a smooth DNS switchover without affecting your existing services.
NoteSimulated access is equivalent to normal CDN access and incurs charges for basic CDN services and value-added services, if they are tested. The billing follows the standard CDN billing method. For more information, see Billing components.
2. Recommended configurations
After you configure the domain name and origin server, click Next to go to the Recommended Configurations page.
The Recommended Configurations page provides four configuration options: Improve cache hit ratio, Improve access performance, Prevent excessive charges, and Enhance access security. These configurations can improve the cache hit ratio, access performance, and security of CDN.
You can configure features based on your business needs, or skip this step and return to it later. To return to this step, find the domain name on the Domain Names page and click Quick Configuration in the Action column.
Improve cache hit ratio
Cache Expiration
Proper cache rules can maximize the performance of CDN and reduce unnecessary origin requests. Cache rules are matched in order, and the first matching rule is applied. Based on the characteristics of your resources, you can configure appropriate cache expiration times. The following table describes the recommended configurations:
File type | File extensions | Expiration time | Description |
Images/audio/video |
| 30 days | Content rarely changes |
Static scripts |
| 1 hour | May change frequently with version releases |
Homepage |
| No cache (0 seconds) | Ensures users always get the latest page structure |
Ignore Parameters
After you enable the Ignore URL parameters feature, CDN nodes remove the parameters that follow the question mark (?) in a URL when the nodes generate cache keys. This way, requests from clients that contain different parameters for the same resource can match the same cache entry. This improves the cache hit ratio and reduces origin traffic.

Improve access performance
Range Origin Fetch
Range origin fetch uses the Range header in HTTP requests to specify byte ranges for file downloads. If you enable range origin fetch, CDN nodes retrieve only the uncached parts of large files from the origin server. This prevents the retransmission of full files, improves the response speed, and reduces origin traffic.
If your client supports Range requests, select Match Client. For images, use a 512 KB segment size. For videos or large files, use 1 MB, 2 MB, or 4 MB segment sizes. On the first origin request, the CDN node rounds up the client's Range size to request the origin. Subsequent requests use the specified segment size.
For video or large files, select Enable Range Origin Fetch (Recommended for Large File Delivery) and choose a 1 MB, 2 MB, or 4 MB segment size. Regardless of whether the client uses Range requests, all CDN origin requests use the specified segment size.
Gzip Compression
You can use Gzip compression for files that are 1 KB to 10 MB in size to reduce the transfer size, improve transfer efficiency, and save bandwidth.
CDN does not compress files that are smaller than 1 KB or larger than 10 MB. Common image and video files are already compressed. Therefore, Gzip compression has no effect. Before you enable this feature, read the notes in Gzip compression.

Prevent excessive charges
To prevent high bills that are caused by attacks or hotlinking that lead to sudden high bandwidth usage, you can configure usage caps to limit the bandwidth, traffic, and number of HTTPS requests for your domain name. This reduces losses that are caused by traffic spikes. For more information, see Configure usage caps.
After a cap is triggered, the accelerated domain name is temporarily taken offline and becomes inaccessible. If you want to receive only alert notifications when the usage exceeds the threshold, you can set up traffic monitoring alerts.
Set thresholds based on the historical data of traffic, bandwidth, and HTTPS requests of your website. If you do not have this information, you can skip this configuration for now. After your system runs in a stable manner, you can use the Usage Query feature of CDN to check the usage of your domain name and then configure usage caps.
Traffic cap
If your billing method is pay-by-traffic, you can configure this feature. Set a threshold based on historical traffic. The system tracks the total traffic for your domain name over a specified period. If the cumulative traffic exceeds the threshold, the cap rule is triggered and the domain name is taken offline. The domain name is restored after the unblock time.
Bandwidth cap
If your billing method is pay-by-peak-bandwidth, you can configure this feature to control your billing bandwidth limit. If the real-time monitored bandwidth exceeds the threshold, the cap rule is triggered and the domain name is taken offline. The domain name is restored after the unblock time.
HTTPS request cap
If your accelerated domain name requires HTTPS access and you have a clear budget for HTTPS requests, you can configure this feature. If the number of cumulative HTTPS requests exceeds the threshold, the cap rule is triggered and the domain name is taken offline. The domain name is restored after the unblock time.
Enhance access security
HTTPS Certificate
If your application already supports HTTPS, you must configure an HTTPS certificate for it in CDN. Otherwise, your domain name will no longer support HTTPS.
If your domain name does not support HTTPS and you do not plan to enable it, you can skip this configuration.
Enabling HTTPS generates HTTPS requests. HTTPS request fees cannot be offset by CDN data transfer plans. Ensure that your account has a sufficient balance or purchase an HTTPS request plan to avoid service suspension due to overdue payments. For more information, see Static HTTPS requests.
If you purchased a certificate from Alibaba Cloud Certificate Management Service, select SSL Certificates Service and then select the certificate from the Certificate Name list. If you cannot find the certificate, make sure that the domain name that is bound to the certificate matches the accelerated domain name.
If you use a certificate that is issued by a third-party provider, select Custom Certificate (Certificate+Private Key). After you specify a Certificate Name, upload the Certificate (Public Key) and Private Key. The certificate is saved to Alibaba Cloud Certificate Management Service. You can view the certificate in My Certificates.

Referer Black/Whitelist
The Referer blacklist/whitelist feature uses the Referer field in HTTP request headers to control access and prevent hotlinking. Blacklists and whitelists are mutually exclusive. You can enable only one at a time. For more information, see Configure Referer blacklist/whitelist.
You can Customize and subscribe to operations reports beforehand. Operations reports provide statistics such as PV/UV, Region and ISP, Domain ranking, top Referers, Top URLs, Top origin-fetch URLs, and Top client IPs. You can use this data to configure your Referer Black/Whitelist.
3. Configure CNAME
Before you integrate CDN, requests are sent directly to your server. After the integration, requests are redirected to the nearest CDN node, which then retrieves resources from your origin server. To enable this redirection, you must configure a CNAME record.
A CNAME record is a DNS record type that maps one domain name to another. For more information, see Introduction to CNAME records.
5. Resource prefetch
After you integrate CDN for the first time, prefetch popular static resources to CDN edge nodes. This allows users to retrieve resources directly from edge nodes, preventing slow initial access and improving the user experience.
Log on to the CDN console.
In the navigation pane on the left, click Purge and Prefetch.
On the Purge/Prefetch tab, set Operation Type to Prefetch.
In the Prefetch Content field, enter the full URL of each file to prefetch. Enter one URL per line. Directory prefetch is not supported. For example:
https://www.example.com/install/package.zip.Click Submit to start the prefetch task.
On the Operation Records tab, you can view the details and progress of the task. The task is complete when its progress reaches 100%.
Prefetch tasks cannot be aborted after they are submitted.
The time required for a prefetch task to complete depends on the size and number of files, and the performance of the origin server. A prefetch task usually takes 5 to 30 minutes to complete.
6. Verify that CDN caching is effective
If you still cannot access your site or you encounter errors after you complete the preceding steps, see Troubleshoot access issues.
You have now completed the main CDN configuration. CDN can now accelerate access to your website.
References
Troubleshooting common CDN issues
Five competitive advantages of CDN
Best practices for preventing CDN hotlinking














