Alibaba Cloud CDN allows you to refresh and prefetch resources. The refresh feature forces CDN nodes to delete cached resources and retrieve the latest resources from origin servers. The prefetch feature allows CDN nodes to retrieve frequently accessed resources from origin servers during off-peak hours. This increases the cache hit ratio.

Overview

Alibaba Cloud CDN supports the refresh and prefetch features. The following section describes how these features work:
  • Refresh

    Forces CDN nodes to delete all resources that are cached on them. When a CDN node receives a request, the CDN node redirects the request to the origin server to retrieve the requested resources. The retrieved resources are returned to the client and cached on the CDN node. The refresh feature reduces the cache hit ratio.

  • Prefetch

    Prefetches resources from origin servers and caches the resources on CDN nodes. When a CDN node receives a request, the CDN node directly returns the requested resources to the client because resources are already cached on CDN nodes. The prefetch feature increases the cache hit ratio.

Scenarios

The following table describes the scenarios where the refresh or prefetch feature is commonly used.
Feature Scenario
Refresh
  • Update and release resources

    After resources on your origin server are updated, you can submit the URLs or directories of the updated resources to Alibaba Cloud CDN. Then, Alibaba Cloud CDN refreshes the resources that are cached on CDN nodes. This ensures that visitors can retrieve up-to-date resources from CDN nodes.

  • Delete resources that violate the limits of Alibaba Cloud CDN

    After you delete resources that violate the limits described in Limits from your origin server, visitors can still access the resources because the resources are cached on CDN nodes. In this case, you must submit the URLs of the resources to Alibaba Cloud CDN to update the CDN cache.

Prefetch
  • Support major events

    If you want to hold a major event, you can push the static resources of the event page to CDN nodes. After the event starts, visitors can access the static resources, which are already cached on CDN nodes. This accelerates content delivery.

  • Release installation packages

    Before you release an installation or upgrade package of a product, you can push the package to CDN nodes. After the product is launched, visitors can download the package from CDN nodes. This accelerates content delivery and reduces loads on origin servers when a large number of visitors want to access your resources.

Usage notes

  • After a refresh task is submitted and completed, some resources are removed from the CDN nodes. When a CDN node receives a request that requests the removed resources, the CDN node redirects the request to the origin server to retrieve the resources. The retrieved resources are returned to the client and cached on the CDN node. After multiple refresh tasks, a large amount of resources are removed from CDN nodes. This increases the number of requests that are redirected to the origin server. The back-to-origin routing process consumes more bandwidth resources and the origin server may be overwhelmed.
  • After a refresh task is submitted and completed, L2 CDN nodes immediately start to retrieve resources from the origin server. Therefore, a large number of refresh tasks cause a large number of concurrent download tasks. This increases the number of requests that are redirected to the origin server. The back-to-origin routing process consumes more bandwidth resources and the origin server may be overwhelmed.

Refresh resources

For more information about how to automate refresh and prefetch tasks, see Run a script to prefetch content.

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Refresh & Prefetch.
  3. On the Refresh Cache tab, create a refresh task.
    Refresh and prefetch resources
    Parameter Description
    Operation Select Refresh.
    Object You can select URL or Directory.
    URL
    • Refresh resources based on URLs
      • Each URL must start with http:// or https://.
      • Enter only one URL on each line.
      • Each Alibaba Cloud account can submit at most 2,000 URLs per day, and at most 1,000 URLs at a time. You can submit at most 1,000 URLs for each domain name per minute.

        If your workloads within your Alibaba Cloud account require a daily bandwidth limit greater than 200 Mbit/s, you can submit a ticket to increase the quota. Alibaba Cloud will review your application and then increase the quota properly.

    • Refresh resources based on directories
      • Each URL must start with http:// or https:// and end with a forward slash (/).
      • Enter only one URL on each line.
      • Each Alibaba Cloud account can submit at most 100 directories per day, and at most 100 directories at a time. Subdirectories are supported. You can apply for a quota increase. After your application is approved, you can submit at most 1,000 directories at a time.

        If your workloads within your Alibaba Cloud account require a daily bandwidth limit greater than 200 Mbit/s, you can submit a ticket to increase the quota. Alibaba Cloud will review your application and then increase the quota properly.

  4. Click Submit.
  5. Check the refresh progress.
    After you submit a refresh task, you can check the progress and details on the Records tab. The progress depends on the number of subjects to be refreshed. It may take some time to complete the task.
    Note You can enable the Auto CDN Cache Update feature in the Object Storage Service (OSS) console for OSS to automatically update CDN caches. However, you cannot view these tasks in the CDN console.

Prefetch resources

For more information about how to automate refresh and prefetch tasks, see Run a script to prefetch content.

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Refresh & Prefetch.
  3. On the Refresh Cache tab, create a prefetch task.
    Prefetch resources
    Parameter Description
    Operation Select Prefetch.
    Object Only URL is supported.
    URL
    • Each URL must start with http:// or https://.
    • Enter only one URL on each line.
    • Each Alibaba Cloud account can submit at most 500 URLs per day, and at most 100 URLs at a time.

      If your workloads within your Alibaba Cloud account require a daily bandwidth limit greater than 500 Mbit/s, you can submit a ticket to increase the quota. Alibaba Cloud will review your application and then increase the quota properly.

    • The prefetch queue of each Alibaba Cloud account can contain at most 100 URLs. Alibaba Cloud CDN performs prefetch tasks in order of submittal time of the URLs.
  4. Click Submit.
  5. Check the prefetch progress
    After you submit a prefetch task, you can view the progress and details on the Records tab. The progress depends on the number of subjects to be prefetched. It may take some time to complete the task.

Related API operations

You can call API operations listed in the following table to refresh and prefetch resources.
API Description
PushObjectCache Prefetches resources from origin servers to L2 CDN nodes. This reduces loads on origin servers because visitors can hit cache upon their first visits.
RefreshObjectCaches Refreshes files on CDN nodes. After a file is refreshed, the version cached on CDN nodes immediately expires. When a client requests the file, the CDN node redirects the request to the origin server to retrieve the latest version of the file. Alibaba Cloud CDN allows you to refresh the content of multiple URLs at a time.
DescribeRefreshTasks Queries the status of refresh or prefetch tasks that belong to an accelerated domain name.
DescribeRefreshTaskById Queries the status of refresh or prefetch tasks by ID for an accelerated domain name.
DescribeRefreshQuota Queries the maximum and remaining numbers of URLs and directories that can be refreshed daily, the maximum and remaining numbers of times that you can prefetch content daily, and the maximum and remaining numbers of URLs and directories that can be blocked daily.