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

Go to the section that you are interested in:

Overview

Alibaba Cloud CDN supports the refresh and prefetch features. The following section describes how these features work:
  • Refresh: clears all resources that are cached on the edge nodes. When an edge node receives a request, the edge 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 node. The refresh feature reduces the cache hit ratio.
  • Prefetch: prefetches resources from origin servers and caches the resources on the edge nodes. When an edge node receives a request, the edge node directly returns the requested resources to the client because the resources are already cached on the edge 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 publish 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 the edge nodes. This ensures that visitors can retrieve up-to-date resources from the edge 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 the edge nodes. In this case, you must use the refresh feature to update the CDN cache so that the resources are deleted from the edge nodes.

Prefetch
  • Provide support for major events

    If you want to hold a major event, you can push the static resources of the event page to the edge nodes. After the event starts, visitors can access the static resources, which are already cached on the edge 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 the edge nodes. After the product is launched, visitors can download the package from the edge nodes. This accelerates content delivery and reduces loads on origin servers when a large number of visitors want to access your resources.

Precautions

  • After a refresh task is submitted and completed, some resources are removed from the edge nodes. When an edge node receives a request for the removed resources, the node redirects the request to the origin server to retrieve the resources. The retrieved resources are returned to the client and cached on the node. After multiple refresh tasks, a large amount of resources is removed from the edge 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, the edge 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.
  • Resource Access Management (RAM) users must acquire required permissions before they can refresh or prefetch resources. For more information, see Authorize a RAM user to prefetch and refresh resources.

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/Prefetch tab, create a refresh task.
    Refresh and prefetch
    Parameter Description
    Operation Select Refresh.
    Operation Method 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 up to 10,000 URLs per day and up to 1,000 URLs at a time. You can submit up to 1,000 URLs for each domain name per minute.

        If the daily peak bandwidth value of your workloads 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.

    • 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 up to 100 directories per day and up to 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 the daily peak bandwidth value of your workloads 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.

  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 If Auto CDN Cache Update is enabled in the Object Storage Service (OSS) console, you cannot check the automatic refresh tasks in the Alibaba Cloud 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/Prefetch tab, create a prefetch task.
    Prefetch
    Parameter Description
    Operation Select Prefetch.
    Operation Method Only URL is supported.
    URL
    • Each URL must start with http:// or https://.
    • Enter only one URL on each line.
    • By default, each Alibaba Cloud account can submit up to 1,000 URLs per day. If the daily peak bandwidth value of your workloads 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.
    • The prefetch queue of each Alibaba Cloud account can contain up to 50,000 URLs. Alibaba Cloud CDN runs prefetch tasks based on the time at which you submit the URLs. 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 that a prefetch task takes is based on the average size of the files to be prefetched. The smaller the average file size, the less time the prefetch task takes.
  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.

API references

You can call API operations listed in the following table to refresh and prefetch resources.
API operation Description
PushObjectCache Prefetches resources from origin servers to the edge nodes. This reduces loads on origin servers because visitors can hit cache upon their first visits.
RefreshObjectCaches Refreshes files on Alibaba Cloud CDN edge nodes. After files are refreshed, the original file content immediately becomes invalid. If clients request the original file content, Alibaba Cloud CDN redirects the requests to the origin server where the content is stored. Then, Alibaba Cloud CDN caches the latest content to the edge nodes and returns it to the clients. Alibaba Cloud CDN allows you to refresh content from multiple URLs at a time.
DescribeRefreshTasks Queries the status of refresh or prefetch tasks.
DescribeRefreshTaskById Queries the status of refresh or prefetch tasks by ID.
DescribeRefreshQuota Queries the maximum and remaining numbers of URLs and directories that can be refreshed, the maximum and remaining numbers of URLs that can be prefetched, and the maximum and remaining numbers of URLs and directories that can be blocked on the current day.
DescribeCdnUserQuota Queries the maximum and remaining quota.