Alibaba Cloud CDN quick start

更新时间:
复制 MD 格式

This topic provides a quick start for Alibaba Cloud CDN, including adding a domain name, configuring an origin, creating a CNAME record, and applying recommended performance and security settings.

Note

The examples in this topic use www.example.com as the domain name and 10.10.10.1 as the origin server IP.

How Alibaba Cloud CDN accelerates content delivery

If you are already familiar with how a CDN works, you can skip this section and proceed to the configuration.

How Alibaba Cloud CDN accelerates content delivery

When you enter a URL in a browser, content such as a webpage, video, or image appears on your screen. This seemingly simple action involves a complex series of background operations. This topic uses a simple request flow to explain how Alibaba Cloud CDN accelerates this process.

Basic request process

image

To retrieve an image from the domain name www.example.com, your browser must first query a DNS server. The DNS server resolves the domain name to its corresponding IP address, 10.10.10.1. The browser then uses this IP address to connect to the server and retrieve the image.

Note
  • A domain name is like a person's name, and an IP address is like their physical address. To find someone, you look up their address by name. Network requests work similarly.

  • A DNS server is like a large database that stores the mappings between domain names and IP addresses. For more information about DNS servers and domain names, see DNS basics.

Request process with Alibaba Cloud CDN

image

As traffic to www.example.com increases, server performance limits and network conditions can slow down content delivery. In this case, Alibaba Cloud CDN can effectively accelerate requests.

A CDN is deployed between users and an origin server. When a request reaches a CDN node, the node serves the content from its cache if available. If the content is not cached (a cache miss), the node retrieves the content from the origin server, caches it, and then delivers it to the user. This process accelerates all subsequent requests for the same content.

Note
  • Request acceleration is a basic feature of Alibaba Cloud CDN. For an overview and advanced features, see What is Alibaba Cloud CDN.

  • Alibaba Cloud CDN accelerates content delivery from outside your origin server's architecture. It is non-intrusive and does not require you to modify your business code.

  • The actual request flow is more complex than this example shows. This diagram is simplified to explain the basic principles of how Alibaba Cloud CDN works.

Quick access to Alibaba Cloud CDN

Complete the following configuration to enable content acceleration. If you prefer a video tutorial, you can also watch our Quick Start.

Note

Before using Alibaba Cloud CDN, complete the following prerequisites:

  1. You need to complete real-name verification for your Alibaba Cloud account. If you do not have an account, you can create one on the account registration page.

  2. Activate the CDN service.

Add domain name and origin server

  1. Configure domain name

    To enable acceleration for your domain name, add it to Alibaba Cloud CDN as an Domain Name to Accelerate. This allows Alibaba Cloud CDN to identify and accelerate requests for the domain.

    Add a domain name

    1. Log on to the CDN console.

    2. In the left-side navigation pane, click Domain Names.

    3. Click Add Domain Name. Configure Region, Domain Name to Accelerate, and Business Type. You can leave the other parameters at their default values.

    Note
    • An Domain Name to Accelerate is the domain name you add to Alibaba Cloud CDN for acceleration. It is also the domain name that end users access. In this example, enter www.example.com.

    • www.example.com and example.com are two different domain names. If you want to accelerate both domain names, you must add www.example.com and example.com separately in the CDN console and configure a CNAME record for each. You cannot point the CNAME record of an apex domain directly to the CDN CNAME address of a subdomain.

    • For Region, select an acceleration region that suits your business needs. This example uses Chinese Mainland Only. If the acceleration region includes the Chinese mainland, the domain name requires an ICP filing to be accessible.

    • For Business Type, select a type that fits your use case. This example uses Image and Small File.

    • When Region is set to Global (Excluding the Chinese Mainland), you can enable the Global Resource Plan. When enabled, your domain name leverages more POP resources but has limited feature support. For more information, see Features supported after the Global Resource Plan is enabled. Evaluate this feature carefully before enabling it.

  2. Q: Considerations for a unified accelerated domain name

    When you configure a unified accelerated domain name, consider the following:

    1. Business type selection: Select 'Image and Small File' to optimize for static resource acceleration.

    2. Shared cache: If multiple accelerated domain names serve identical content from the origin server, enable shared cache to improve the cache hit ratio.

    3. HTTPS support: To support HTTPS access, you must configure a separate SSL certificate for each accelerated domain name.

    4. Origin host header settings: Set the origin host header to the origin's actual domain name to prevent host header mismatches.

    5. Domain name addition rules: Add each domain name as a separate accelerated domain name in Alibaba Cloud CDN. For example, www.example.com and example.com are two different domain names and must be added as accelerated domain names and configured with CNAME records separately in the CDN console.

  3. Verify domain ownership

    Alibaba Cloud CDN requires domain ownership verification to confirm that you own the domain name. You can skip this step if you have already verified the domain or if no verification prompt appears.

    Verify domain ownership

    Important

    Do not close the verification tab until the verification is complete.

    DNS record verification (Recommended)
    1. On the verification tab of the Add Domain Name page, click Method 1: DNS Settings to obtain the host record and record value.

      Go to your DNS provider and add a TXT record. Set Host to verification and Value to the verification value displayed on the page. After you configure the record, select Configured and click Verify to complete the domain ownership verification.

    2. Add a TXT record at your DNS provider. The following example shows how to add a TXT record in Alibaba Cloud DNS. The process is similar for other DNS providers, such as Tencent Cloud or Xinnet.

      Configure a TXT record

      1. Log on to the Alibaba Cloud DNS console.

      2. On the Public Zone page, find the root domain name example.com of your accelerated domain name and click DNS Records in the Actions column.

      3. Click Add Record. Set Type to TXT. Enter the Host and Value provided by Alibaba Cloud CDN in Step 1. You can leave the other parameters at their default values.

      1. Click OK to add the record.

      Note

      For more information about the definitions of and differences between root domains and subdomains, see Domain name basics.

    3. Wait for the TXT record to take effect. Then, return to the verification tab in the CDN console and click Verify to complete the verification.

      If the "Verification failed" message appears, check whether your TXT record is correctly configured and try again after the DNS record takes effect.

      Check whether the TXT record has taken effect

      Use the following method to check if the TXT record for the accelerated domain name www.example.com is correct and has taken effect:

      Windows

      Open Command Prompt and run the nslookup -type=TXT verification.example.com command. Check the TXT result to confirm that the DNS record is correct and has taken effect.

      The following code provides a sample command output.

      C:\Users\xxx> nslookup -type=TXT verification.example.com
      Server:  UnKnown
      Address:  fd00:1::1
      DNS request timed out.
          timeout was 2 seconds.
      Non-authoritative answer:
      verification.example.com    text =
              "verify_0xxx...xxxff22"

      macOS/Linux

      In the terminal, run the nslookup -type=TXT verification.example.com command. Check the TXT result to confirm that the DNS record is correct and has taken effect.

      [root@xxx ~]# nslookup -type=TXT verification.example.com
      Server:		 xxx.xxx.xxx.xxx
      Address:	 xxx.xxx.xxx.xxx#53
      Non-authoritative answer:
      verification.example.com	text = "verify_xxx981c5ebff22"
      Authoritative answers can be found from:
      Note
      • In the nslookup command, the record type is TXT. The domain name to verify is your original domain name with the hostname replaced by verification. For example, if your accelerated domain name is www.example.com, the domain name you need to verify is verification.example.com.

      • A new TXT record typically starts propagating immediately. Modifications to an existing record take effect after its time to live (TTL) expires.

      • If the nslookup command is not installed on your Linux system, run yum install bind-utils on CentOS or apt-get install dnsutils on Ubuntu to install it.

    File verification
    1. On the verification page, click Method 2: Verification File.

      Follow the on-screen instructions to complete the file verification: download the verification.html file, upload it to the root directory of your origin server (ensure it is accessible at http://example.com/verification.html), and then click Verify to complete the domain ownership verification.

    2. Click verification.html to download the verification file.

    3. Upload the verification file to the root directory of your origin server, such as your ECS, OSS, CVM, COS, or EC2 instance. For example, if your accelerated domain name is www.example.com, upload the file to the root directory of example.com.

    4. After you confirm that the file is accessible at http://example.com/verification.html, click Verify.

      Alibaba Cloud CDN accesses the http://example.com/verification.html file on your server for verification.

      • If the content of the file matches the expected verification value, the verification is successful.

      • If the verification fails, make sure that the file URL is accessible and that you uploaded the correct file.

  4. Configure origin server information

    An origin server is a web server that hosts your application content. When a cache miss occurs, a CDN node retrieves the requested resource from the origin server.

    Configure origin server information

    1. After you configure the business information for the domain name, click Add Origin Server in the Origin Servers section.

    2. In the dialog box that appears, select the type of origin server and enter its address.

    3. Enter the Port based on your origin server's settings. By default, port 80 for HTTP is used.

      In the Add Origin Server dialog box, select an Origin Info type (OSS Domain, IP, Site Domain, or Function Compute Domain). Set the Priority (0-127, lower values are higher) and Weight (1-100). For example, you can set a primary origin's priority to 20 and a backup's to 30. For Port, you can use the default HTTPS port 443 or a custom port from 1 to 65535. After you complete the configuration, click OK.

    Note
    • This example uses the IP address 10.10.10.1 to configure the origin server.

      • To accelerate resources in OSS, select OSS Domain for Origin Info.

      • To accelerate resources deployed on an ECS instance, select IP for Origin Info and enter the public IP address of the ECS instance.

      • If your resources are on a server that cannot be accessed by IP address, select Site Domain for Origin Info and enter the domain name of the origin server. The origin domain name cannot be the same as the accelerated domain name. Otherwise, a DNS resolution loop occurs.

      • To accelerate resources in Function Compute, select Function Compute Domain for Origin Info, and then select the region and domain name based on your Function Compute resources.

    • If your origin server hosts multiple websites, you must also configure an origin host header.

    • For more information about origin server parameters, see Configure an origin server.

    • For best practices for using Alibaba Cloud CDN with OSS, see Accelerate access to OSS resources by using Alibaba Cloud CDN.

  5. Verify accelerated domain name

    After you add the accelerated domain name, we recommend that you test it on a local machine first. This allows you to switch DNS records without impacting production traffic. After you verify that the accelerated domain name is working correctly, point its DNS record to the CNAME address.

    Note

    Simulated access incurs standard CDN charges. For more information, see Billing components.

    Verify the accelerated domain name

    1. Obtain the CNAME address of the accelerated domain name.

      1. Log on to the CDN console.

      2. In the left navigation pane, click Domain Names.

      3. On the Domain Names page, copy the CNAME address that corresponds to the accelerated domain name.

        Note

        Copy the CNAME address only when its status is Normal.

        In the domain name list on the Domain Names page, the corresponding CNAME address (for example, xxx.alikunlun.com) is displayed in the CNAME column.

    2. Obtain the IP address that corresponds to the CNAME. In a command-line interface such as CMD, PowerShell, or Terminal, run the nslookup command to query the CNAME address for its corresponding IP addresses. Example:

      nslookup www.example.com.w.kunlunle.com 
      nslookup www.example.com.w.kunlunle.com
      Server:         100.100.XX.XX
      Address:        100.100.XX.XX#53
      Non-authoritative answer:
      www.example.com.w.kunlunle.com	canonical name = xxx.p.kunlunle.com.
      Name:   xxx.p.kunlunle.com
      Address: 117.XX.XX.214
      Name:   www.example.com.w.kunlunle.com
      Address: 2408:XXXX:1:3::3fa
    3. Modify the hosts file on your local computer.

      Add an entry that maps the IP address obtained in the previous step to the accelerated domain name in the local hosts file. The IP address must come before the accelerated domain name. Do not reverse the order. The following example uses the IP address 117.XX.XX.214, obtained from the preceding nslookup command.

      Windows

      1. Go to the C:\Windows\System32\drivers\etc directory and open the hosts file by using a text editor, such as Notepad, with administrator permissions.

      2. Edit the hosts file. The file content may be similar to the following:

        # localhost name resolution is handled within DNS itself.
        # 127.0.0.1       localhost
        # ::1             localhost

        Add the obtained IP address and the accelerated domain name to the end of the file. Example:

        117.XX.XX.214   www.example.com
      3. Save the changes. After you finish editing, select File > Save or press Ctrl+S.

      4. (Optional) Flush the DNS cache to ensure that the DNS changes take effect immediately.

        Open Command Prompt with administrator permissions, enter the following command, and then press Enter:

        ipconfig /flushdns

      macOS

      1. Open Terminal and run the following command to open the hosts file with administrator permissions.

        sudo vim /etc/hosts
      2. Edit the hosts file. The file content may be similar to the following:

        ##
        # Host Database
        #
        # localhost is used to configure the loopback interface
        # when the system is booting.  Do not change this entry.
        ##
        127.0.0.1   localhost
        255.255.255.255 broadcasthost
        ::1         localhost

        Add the obtained IP address and the accelerated domain name to the end of the file. Example:

        117.XX.XX.214   www.example.com
      3. Save the changes and exit.

        Press the Esc key to exit insert mode, then type :wq and press Enter to save the file and exit Vim.

      4. (Optional) Flush the DNS cache to ensure that the DNS changes take effect immediately.

        In Terminal, enter the following command and press Enter:

        sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    4. Test whether the accelerated domain name is accessible.

      After you modify the hosts file, open a browser and access the accelerated domain name to test connectivity. You can view the test results by using the browser's developer tools.

      • If the IP address in the Remote Address field matches the one you added to your hosts file, the configuration is successful. You can then proceed to configure the CNAME record with your DNS provider. Open the Network panel in your browser's developer tools, select the request entry that corresponds to the accelerated domain name, and go to the Headers panel. In the General section, confirm that the Status Code is 200 OK and check the IP address displayed in the Remote Address field.

      • If the IP address in the Remote Address field does not match the IP address you added to the hosts file, the configuration is incorrect. Check whether the IP address in the hosts file is the correct IP address of the CNAME.

      After you can access the accelerated domain name, you can perform other verification tests on your local machine if needed.

Recommended Configurations

After you configure the domain name and origin server, click Next to go to the Recommended Configurations page.

The Recommended Configurations section provides four configurations, Improve cache hit ratio, Improve access performance, Cost control, and Improve access security, to quickly improve the cache hit ratio, access performance, and security of your CDN.

You can configure features based on your business needs or skip this step. You can access this page again later by clicking Quick Configuration in the Action column on the Domain Names page.

Improve cache hit ratio

Cache Expiration

Configure cache rules to reduce origin fetch requests. Rules are matched in order, and the first matched rule takes effect. Based on your resource characteristics, set a suitable cache expiration time. The following table shows recommended configurations for rules based on file extensions.

File type

File extension

Expiration time

Description

Images/Audio/Video

jpg,png,gif,mp3,mp4

30 days

Resource content does not change often.

Static scripts

js,css

1 hour

May change frequently with version releases.

Website homepage

html

Do not cache (0 seconds)

Ensures that users always get the latest page structure.

Ignore Parameters

When you enable the ignore URL parameters feature, CDN points of presence (POPs) remove the parameters that follow the question mark (?) in a URL when generating a cache key. This allows requests for the same resource that have different parameters to hit the same cache. This improves the cache hit rate and reduces origin fetch traffic.

In the Ignore URL Parameters dialog box, set Mode to Keep Specified Parameters or Delete Specified Parameters. Set Ignore URL Parameters to Yes. In the Keep Specified Parameters field, enter the parameters that you want to keep. You can enter up to 10 parameters, separated by commas. If you enable Keep Origin Fetch Parameters, all parameters are kept for origin fetch requests. If this feature is disabled, the parameters for origin fetch requests are the same as the parameters in the cache key. Click OK to save the configuration.

Improve access performance

Range Origin Fetch

Range origin fetch retrieves only the uncached byte ranges of large files from the origin server. This prevents the re-transmission of entire files.

If the client has configured range origin fetch parameters, select Match Client. Use 512 KB chunks for images. For videos or large files, use 1 MB, 2 MB, or 4 MB chunks based on file size.

If the accelerated resources are videos or large files, select Enable Range Origin Fetch (Recommended for Large File Delivery). Select 1 MB, 2 MB, or 4 MB chunks based on file size. All origin fetch requests from CDN nodes will then use the specified chunk size.

Gzip Compression

Use Gzip compression for accelerated files between 1 KB and 10 MB to reduce the amount of data transferred.

This feature does not compress files smaller than 1 KB or larger than 10 MB. Common image and video file types are already compressed, so enabling Gzip for them has no effect. Before you enable this feature, read the precautions in Gzip compression.

Turn on the Gzip compression switch. Do not enable this feature if your origin server files have their own MD5 verification mechanism.

Cost control

To prevent high bills from sudden bandwidth spikes caused by attacks or unauthorized usage, configure a usage cap to control the maximum bandwidth, traffic, and number of HTTPS requests for your domain name. For more information, see Configure a usage cap.

Important
  • When a capping rule is triggered, the accelerated domain name is temporarily taken offline and becomes inaccessible. If you only want to receive an alert when usage exceeds the threshold, set traffic monitoring alerts.

  • Set the threshold based on your website's historical traffic, bandwidth, and number of HTTPS requests. If you are unsure about this data, skip this configuration for now. After your system is stable, use the CDN Usage Query feature to view usage information for the accelerated domain name, and then configure the usage cap.

Traffic Cap

If your billing method is the default Pay-by-traffic, configure this feature. Set the threshold based on historical traffic. The system calculates the total traffic for the domain name over a specified period. When the cumulative traffic exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.

Bandwidth Cap

If your billing method is Pay-by-peak-bandwidth, configure this feature to effectively control the upper limit of your billable bandwidth. When the real-time bandwidth exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.

HTTPS Requests Cap

If your accelerated domain name requires HTTPS access and you need to control the budget for HTTPS requests, configure this feature. When the cumulative number of requests exceeds the threshold you set, the capping rule is triggered, and the domain name is taken offline. The accelerated domain name is brought back online at the specified unblocking time.

Enhance access security

HTTPS Certificate

If your domain name requires HTTPS access, configure a certificate. Otherwise, HTTPS is unavailable.

Skip this step if HTTPS is not required.

Important

Enabling HTTPS generates static HTTPS requests. The first 5 million static HTTPS requests per month are free. You are charged for requests that exceed this limit. Charges for HTTPS requests cannot be offset by a CDN data plan. Ensure that your account has a sufficient balance or purchase an HTTPS request package to prevent your CDN service from being suspended 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 select your certificate from the Certificate Name list. If you cannot select your certificate, check that the domain name bound to the certificate is the same as the accelerated domain name.

  • If you use a certificate from a third-party provider, select Custom Certificate (Certificate+Private Key). Set a Certificate Name, and then upload the Certificate (Public Key) and Private Key. The certificate is saved in Alibaba Cloud Certificate Management Service. You can view it in My Certificates.

Referer Black/Whitelist

A Referer blocklist/allowlist controls access based on the Referer field in HTTP request headers to prevent resource hotlinking. You can configure a blocklist or an allowlist. The two lists are mutually exclusive. For more information, see Configure a Referer blocklist/allowlist.

Note

You can enable the Customize and subscribe to operations reports feature in advance. Operations reports collect and display user access data, such as PV/UV, Regions and ISPs, Domain Name Ranking, popular referers, Popular URLs, Popular Origin URLs, and Top Client IPs. Then, use the popular referers data to configure the Referer Black/Whitelist.

好的,我将作为一名追求极致简洁的文案本地化专家,开始处理这份 HTML 文档。 我将严格遵循您设定的工作流和核心约束,逐行解析,仅对 、 和 进行压缩和规范化。其余所有内容,包括所有 HTML 属性(特别是 ),都将保持原样。 --- 1. : * : 2 个单词,简洁,符合规则。无需修改。 * : 4 个单词,简洁,符合规则。无需修改。 * : 3 个单词,简洁,符合规则。无需修改。 * : 2 个单词,简洁,符合规则。无需修改。 * : 2 个单词,简洁,符合规则。无需修改。 * : 2 个单词,简洁,符合规则。无需修改。 * : 3 个单词,简洁,符合规则。无需修改。 * : 3 个单词,简洁,符合规则。无需修改。 2. : * 未发现

Q: Hotlink protection and bandwidth limiting for CDN-to-OSS

When your CDN fetches images from OSS, use the following quick configuration settings to enable hotlink protection and control bandwidth costs:

  1. Hotlink protection: In the 'Improve Access Security' section of quick configuration, set up Referer-based hotlink protection with a whitelist of your allowed domain names. Alternatively, use an IP blacklist to block malicious IPs. This prevents unauthorized use of your resources.

  2. Bandwidth limiting: In the 'Prevent Excessive Costs' section of quick configuration, set a bandwidth threshold. If this threshold is exceeded, a capping rule is triggered that takes the accelerated domain name offline to control traffic and costs. The domain automatically comes back online after the unblocking period ends.

3. Configure CNAME

Configure a CNAME record to point your domain name to the nearest CDN point of presence (POP) to route user requests through Alibaba Cloud CDN for acceleration.

A CNAME record is a type of DNS record that maps one domain name to another. For more information, see Introduction to CNAME records.

Configure a CNAME record with your DNS provider

  1. In the Alibaba Cloud CDN console, go to the Domain Names page. Find your accelerated domain name and copy its CNAME value. If the value is empty, wait five seconds and refresh the page.

  2. Add a CNAME record with your DNS provider. The procedure for configuring a CNAME record varies based on the DNS provider. This topic provides instructions for Alibaba Cloud and Tencent Cloud.

    Alibaba Cloud

    If your DNS provider is Alibaba Cloud, follow these steps to configure the CNAME record.

    1. Log in to the Alibaba Cloud DNS console with the Alibaba Cloud account that owns the accelerated domain name.

    2. On the Public Zone page, find the root domain name, such as example.com, and click DNS Records in the Actions column.

    3. Click Add Record.

    4. Set Record Type to CNAME.

      Set Host Record to www, Resolution Request Source to Default, and Record Value to the CNAME address, such as www.example.com.w.kunlun.com. Keep the default TTL of 10 minutes and click OK.

    Important
    • The host record is the prefix of a domain name. For www.example.com, the host record is www. If your accelerated domain name is the root domain name example.com, set the host record to @.

    • A CNAME record and an A record cannot be configured for the same host record. If an A record already exists for the accelerated domain name, you must pause or delete the A record before adding the CNAME record.

    • Pausing an A record to configure a CNAME record may cause a brief service interruption. To minimize the impact on your domain name, perform this operation during off-peak hours based on your traffic patterns.

    1. Click OK.

    Tencent Cloud

    If your DNS provider is Tencent Cloud, follow these steps to configure the CNAME record.

    1. Log in to the DNSPod console.

    2. On the DNS management page for your domain name, click Add Record to add a CNAME record.

      Parameter

      Description

      Example

      Hostname

      • If the accelerated domain name is a subdomain, the host record is the prefix of the subdomain.

      • If the accelerated domain name is a wildcard domain, the host record is *.

      • If the accelerated domain name is the root domain, the host record is @.

      • Subdomain examples:

        • If the accelerated domain name is www.example.com, the host record is www.

        • If the accelerated domain name is www.example.aliyundoc.com, the host record is www.example.

      • Wildcard domain examples:

        • If the accelerated domain name is *.example.com, the host record is *.

        • If the accelerated domain name is *.example.aliyundoc.com, the host record is *.example.

      • Root domain example: If your root domain is example.com and you set the accelerated domain name to example.com, enter @ for the host record.

      Note

      DNS settings apply to your registered domain name (for example, example.com) or its prefix. When you configure the host record, enter only the part to be resolved. For example, to resolve www.example.com, enter www.

      Record Type

      Select CNAME.

      CNAME

      Line Type

      Select Default.

      We recommend that you keep the default value.

      Record Value

      Enter the CNAME value for the accelerated domain name.

      Note

      The CNAME values for a subdomain (such as www.example.com) and a second-level subdomain (such as www.example.aliyundoc.com) are different. To accelerate a second-level subdomain, you must also add it to Alibaba Cloud CDN and map it to its corresponding CNAME value. Alternatively, you can add a wildcard domain to Alibaba Cloud CDN. The CNAME of the wildcard domain can be used by its second-level subdomains. To add a wildcard domain or a second-level subdomain, see Add an accelerated domain name.

      www.example.com.w.kunlunsl.com

      Weight

      This parameter is not required.

      Not applicable

      MX

      This parameter is not required.

      Not applicable

      TTL

      TTL stands for time-to-live. It specifies the duration for which the record is cached by a DNS resolver. A smaller value means that changes take effect faster.

      We recommend that you keep the default value.

    3. Click Save.

  3. Verify the CNAME record.

    Console

    1. In the Alibaba Cloud CDN console, go to the Domain Names page.

    2. Find the target domain name and check its CNAME Status. The Configured status indicates that the CNAME record is active.

    Note
    • After you configure the CNAME record, the CNAME Status in the console may still show as Pending Configuration. If this occurs, refresh the page or wait for about five minutes before checking again.

    CLI

    1. Open Command Prompt (Windows) or Terminal (macOS/Linux).

    2. Run the command nslookup -type=CNAME Domain Name to Accelerate. For example, run nslookup -type=CNAME www.example.com. If the returned canonical name matches the CNAME value for the Domain Name to Accelerate in the Alibaba Cloud CDN console, the CNAME record is active.

      ~ % nslookup -type=CNAME www.example.com
      Server:         30.30.30.xxx
      Address:        30.30.30.xxx
      Non-authoritative answer:
      www.example.com         canonical name = www.example.com.w.kunlun.com.
      Authoritative answers can be found from:

Resource prefetch

After you add a domain name to CDN, you can prefetch popular static resources to CDN POPs. This provides faster access for first-time visitors by serving content directly from the cache.

  1. Log on to the CDN console.

  2. In the navigation pane on the left, click Purge and Prefetch.

  3. On the Purge/Prefetch tab, set the operation type to Prefetch.

  4. In the input box, enter the full URL of each file to prefetch. Enter one URL per line. Prefetching directories is not supported. For example: https://www.example.com/install/package.zip.

  5. Click Submit.

  6. On the operation records tab, view the details and progress of your purge or prefetch tasks. A task is complete when its progress reaches 100%.

Note
  • Submitted purge or prefetch tasks cannot be canceled.

  • The completion time for a prefetch task depends on the file size, number of files, and origin server performance. A task typically takes 5 to 30 minutes.

Step 5: Verify Alibaba Cloud CDN caching

Verify that Alibaba Cloud CDN caching is effective

  1. Windows: Press Windows+R, type cmd in the Run dialog box, and click OK to open Command Prompt.

    macOS: Open Terminal.

  2. Run the "curl -I" command for a resource on your accelerated domain. For example, curl -I www.example.com/10.JPG.

    norman@Norman ~ % curl -I http://xxx/public/picture/xueshan.jpg
    HTTP/1.1 200 OK
    Server: Tengine
    Content-Type: image/jpeg
    Content-Length: 319717
    Connection: keep-alive
    Date: Fri, 07 Feb 2025 06:15:50 GMT
    x-oss-request-id: 67xxx333314984F6
    Vary: Origin
    x-oss-cdn-auth: success
    Accept-Ranges: bytes
    ETag: "F641480662xxx1E55F6C851AF"
    Last-Modified: Thu, 14 Nov 2024 01:42:56 GMT
    x-oss-object-type: Normal
    x-oss-hash-crc64ecma: 14568304759889530959
    x-oss-storage-class: Standard
    Content-MD5: 9kFIBmLCpOlayx5V9shRrw==
    x-oss-server-time: 83
    Via: cache40.l2cn3160[0,0,200-0,H], cache55.l2cn3160[1,0], kunlun3.cn7174[0,0,200-0,H], kunlun8.cn7174[7,0]
    Age: 26
    Ali-Swift-Global-Savetime: 1738908951
    X-Cache: HIT TCP_MEM_HIT dirn:-2:-2
    X-Swift-SaveTime: Fri, 07 Feb 2025 06:16:08 GMT
    X-Swift-CacheTime: 2591983
    Timing-Allow-Origin: *
    EagleId: b4a3921c17389089757582374e
  3. If the response headers include the Age, X-Cache, X-Swift-SaveTime, and X-Swift-CacheTime fields, Alibaba Cloud CDN is working correctly.

    Note
    • X-Cache: A value of MISS indicates a cache miss, requiring an origin fetch. A value of HIT indicates a cache hit, and the response was served directly from the cache.

    • Age: Indicates how long, in seconds, the file has been cached on the POP. The response does not include this field for refreshed files or first-time requests. A value of 0 for Age indicates that the cache expired and requires validation with the origin server.

    • X-Swift-SaveTime: Indicates the GMT time when the POP first cached the resource. To convert the time to China Standard Time (UTC+8), add 8 hours.

    • X-Swift-CacheTime: Indicates how long, in seconds, the POP can cache the file. A value of 0 indicates that the request is not cacheable.

Note

If you still cannot access your site or you encounter errors after completing these steps, see Troubleshoot access issues.

After completing these steps, you have configured Alibaba Cloud CDN to accelerate your website.

References