All Products
Search
Document Center

CDN:Refresh and prefetch resources

Last Updated:Feb 25, 2025

The refresh feature allows you to remove cached resources from CDN nodes, compelling the CDN nodes to retrieve the most recent resources from the source server. This feature is useful in situations such as updating and releasing resources, removing non-compliant content, or making domain name configuration adjustments. The prefetch feature enables you to preload popular resources onto CDN nodes ahead of high-traffic periods, thereby reducing the burden on the source server and enhancing the user experience.

Functionality

  • Refresh: This feature marks the cached resources on all CDN nodes as invalid. When users request these resources again, CDN retrieves the updated content from the origin server and delivers it to the users, simultaneously recaching the resources on the CDN nodes. This process can lead to a reduced cache hit ratio.

  • Prefetch: This feature allows the origin server to proactively cache resources on CDN nodes. When you first request these resources, you can directly retrieve the latest versions from the CDN nodes, bypassing the origin server. This process enhances the cache hit ratio.

Scenarios

Function

Applicable scenarios

Refresh

  • Resource Updates And Releases

    After the old resources on the origin server are updated or upgraded, you can submit the URLs or directories of the corresponding resources for refresh to prevent users from accessing outdated cached resources. Users can then directly access the latest resources, which are cached on CDN nodes.

  • Removal Of Non-compliant Resources

    If your origin server contains non-compliant content as mentioned in the Limits, after you delete the resources from the origin server, the resources may still be accessible due to caching on CDN nodes. You can use the URL refresh feature to update the cached resources.

Prefetch

  • First-time integration with Alibaba Cloud CDN

    After you integrate with CDN for the first time, you can choose to prefetch your hot static resources in advance. When users access the resources, the CDN acceleration nodes can directly respond, improving access speed and avoiding slow initial access.

  • Operational Activities

    When operating a large-scale event, prefetch the static resources involved in the event page to CDN nodes in advance. After the event starts, all static resources accessed by users are cached on CDN acceleration nodes and directly responded to by the acceleration nodes.

  • Installation Packages Or Other Large File Releases

    Before releasing new version installation packages or upgrade packages, prefetch the resources to CDN acceleration nodes. After the product is officially published, the download requests from many users are directly responded to by CDN acceleration nodes, improving download speed, significantly reducing the load on the origin server, and enhancing user experience.

Precautions

  • Cache refresh precautions:

    • Submitting numerous refresh tasks can significantly clear the cache, leading to an increase in back-to-origin bandwidth and requests, which in turn increases the load on the origin server. It is advisable to perform this operation during periods of low website traffic.

    • A refresh task typically takes effect within 5 to 6 minutes of submission. If the cache expiration time for files or directories is less than 5 minutes, there is no need to refresh as the cache will automatically update upon expiration.

    • URL refresh, directory refresh, and regex refresh all support shared cache. When a domain name is configured with shared cache, you can submit a refresh task for the primary domain name or any associated domain names to clear the cache.

  • Cache prefetch precautions:

    • After you submit and successfully execute a prefetch task, CDN nodes will immediately retrieve the necessary resources from the source server. Consequently, numerous prefetch tasks can lead to a substantial number of concurrent back-to-origin tasks, causing a sharp rise in back-to-origin bandwidth and requests. It is advisable to carry out this operation when your website experiences low traffic.

    • Each account has a maximum prefetch queue capacity of 100,000 URLs. CDN processes prefetch requests in the order they were submitted. If the prefetch queue reaches its capacity of 100,000 URLs, CDN will not accept new prefetch tasks.

    • The time required to complete a prefetch task varies depending on the file sizes. It typically takes between 5 to 30 minutes, with smaller files being prefetched more quickly.

  • Common precautions:

    • Once URL refresh or cache prefetch tasks are successfully issued, they cannot be stopped until completion.

    • RAM users require authorization to perform refresh and prefetch operations. For more information, see Grant RAM Users Refresh and Prefetch Permissions.

    • Both refresh and prefetch have daily quotas. If your Alibaba Cloud account's daily bandwidth peak exceeds 200 Mbps, you can request an increase in the daily quota through Quota Management. Alibaba Cloud will evaluate and adjust based on your actual business needs.

Note

Refresh or prefetch resources

Refresh resources

  1. Log on to the Alibaba Cloud CDN console.

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

  3. On the Purge/Prefetch tab, select Refresh as the operation type.

  4. Select the appropriate operation method: URL, Directory, or Regex.

  5. Enter or upload the data to be processed in the URL field.

  6. Click Submit.

  7. View the refresh progress.

    Note

    If you have enabled auto CDN cache update in the OSS console, the auto CDN cache update tasks for OSS will not be visible in the CDN console.

Operation method

Related introduction

Precautions

URL

URL refresh refers to refreshing a single file. You need to enter the complete URL path of a single file. Include the protocol header, domain name, path, and file. For example: https://www.example.com/static/picture/earth.jpg

  • When refreshing multiple URLs, enter one URL per line.

  • An account can submit up to 10,000 URL refreshes per day.

Directory

Refresh all files in the folder through the URL path you enter. You need to enter the complete URL directory, which must end with a /. Include the protocol header, domain name, and path. For example: https://www.example.com/static/picture/

  • When refreshing multiple URL directories, enter one URL per line.

  • You can submit up to 100 directory refreshes at a time, and up to 100 directory refreshes for a domain name per minute.

  • Directory refresh uses the "refresh changed resources" method by default. If the Last-Modified information of the resources requested by users has not changed, the old cache information is returned directly without retrieving from the origin server. If you need to force refresh the cache, refer to RefreshObjectCaches - Refresh cache.

Regex

Refreshes based on URLs with regular expressions. If the URL you entered matches the regular expression, it will be refreshed. For example: http://www.example.com/static/picture/[0-9][a-z].*.jpg

  • An account can submit up to 20 URLs containing regular expressions per day.

  • For more information about regex refresh, see Regex refresh description.

Prefetch resources

  1. Log on to the Alibaba Cloud CDN console.

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

  3. On the Purge/Prefetch tab, select Prefetch as the operation type.

  4. Select the appropriate URL for the operation method.

  5. Enter or upload the data to be processed in the URL field.

  6. Click Submit.

  7. View the prefetch progress.

Operation method

Related introduction

Precautions

URL

URL prefetch refers to the prefetching of a single file. You need to enter the complete URL path of a single file. Include the protocol header, domain name, path, and file. For example: https://www.example.com/static/video/earth.mp4

  • When prefetching multiple URLs, enter one URL per line.

  • Directories ending with / are not supported.

  • An account can submit up to 100 URL prefetch tasks at a time and up to 1,000 URL prefetch tasks per day.

Automated refresh or prefetch

For automating refresh or prefetch tasks, see Use Automated Scripts for Refresh and Prefetch.

Verify operation results

Verify refresh or prefetch task results

  • Manual Query

    You can view detailed records and monitor the progress of resource refresh or prefetch tasks on the Records tab. A progress indicator at 100% signifies that the task has been completed. Should the volume of prefetch or refresh tasks be excessive, it may slow down the overall completion rate. Your patience is appreciated.

    image

  • API Query

    Use the DescribeRefreshTaskById API to check the status of refresh or prefetch tasks. For more information, see DescribeRefreshTaskById - Query Refresh Prefetch Task by ID.

Verify file prefetch task results

Execute the following command to check the prefetch results of the file:

# Replace with the URL you prefetched
curl -I 'http://oss.aliyundoc.com/1.png' 

The system will display the following result:

image

If the X-Cache header is present:

  • If X-Cache shows HIT, this means the request successfully hit the cache and the prefetch was effective.

  • If X-Cache shows MISS, this means the request did not hit the cache, either because the prefetch task is incomplete or it failed. You can try prefetching again.

If the X-Cache header is absent:

The absence of the X-Cache header indicates that the resource is not using Alibaba Cloud CDN. Integrate the domain name of the URL with Alibaba Cloud CDN before prefetching the resource by referring to Quickly Integrate with Alibaba Cloud CDN.

FAQ

Related API

You can call API operations to refresh and prefetch resources. For more information, see Refresh and Prefetch API.