All Products
Search
Document Center

CDN:Purge and prefetch resources

Last Updated:Jul 01, 2025

The purge feature allows you to delete resources cached on CDN points of presence (POPs) and force the CDN POPs to retrieve the latest resources from the origin server. This is useful for scenarios such as updating published resources on the origin server, removing violating content, and changing domain name configuration. The prefetch feature enables you to preload popular resources to CDN POPs before peak business hours to reduce origin server load and enhance user experience.

Feature description

  • Purge: Marks cached resources on all CDN POPs as invalid. When users make subsequent requests, CDN retrieves the corresponding resources from the origin server, returns them to users, and re-caches them on CDN POPs. The purge feature reduces the cache hit ratio.

  • Prefetch: Proactively caches resources from the origin server to CDN POPs. When you request resources for the first time, you can obtain the latest resources directly from CDN POPs without retrieving them from the origin server. The prefetch feature increases the cache hit ratio.

Scenarios

Feature

Applicable scenarios

Refresh

  • Resource Updates And Publishing

    After updating or upgrading old resources on the origin server, to prevent users from still accessing outdated cached resources, you can submit the URL or directory of the corresponding resources for refresh. Users can then directly access the latest resources, which are cached to CDN POPs.

  • Violation Content Cleanup

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

Warm-up

  • First-time access to Alibaba Cloud CDN

    After you first access CDN, you can choose to prefetch your hot static resources in advance. When users access these resources, they can receive direct responses from CDN acceleration POPs, improving user access speed and avoiding slow initial access issues.

  • Operational Activities

    When operating a large-scale event, prefetch the static resources involved in the event page to CDN POPs in advance. After the event starts, all static resources accessed by users are already cached to CDN acceleration POPs, which directly respond to requests.

  • Installation Packages Or Other Large File Releases

    Before releasing a new version of an installation package or upgrade package, prefetch the resources to CDN acceleration POPs in advance. After the product is officially published, massive download requests from users will be directly responded to by CDN acceleration POPs, improving download speed, significantly reducing origin server pressure, and enhancing user experience.

Precautions

  • Precautions for cache purge:

    • Submitting many purge tasks clears a significant amount of cache, causing a sudden increase in back-to-origin bandwidth and requests. This increases load on the origin server. We recommend performing this operation during off-peak periods.

    • A purge task takes effect 5 to 6 minutes after being submitted. If the TTL for the resources you want to refresh is less than 5 minutes, you can wait until the TTL expires instead of performing the refresh operation.

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

  • Precautions for cache prefetch:

    • After submitting and successfully executing a prefetch task, CDN POPs will immediately retrieve the required resources from the origin server. Therefore, submitting many prefetch tasks will generate many concurrent back-to-origin tasks, causing a sudden increase in back-to-origin bandwidth and requests. We recommend performing this operation during off-peak periods.

    • Each account's prefetch queue can include up to 100,000 URLs. CDN processes prefetch tasks based on the order of URL submission. When the number of URLs waiting to be prefetched in the prefetch queue reaches 100,000, CDN will reject new prefetch tasks.

    • The time required for a prefetch task to complete is proportional to the size of the prefetched file. In actual practice, most prefetch tasks take 5 to 30 minutes to complete. A task with a smaller average file size takes less time.

  • Common precautions:

    • Once a URL purge or cache prefetch task is issued successfully, it cannot be stopped before the task is completed.

    • To use RAM users for purge and prefetch operations, you need authorization first. For more information, see Authorize a RAM user to prefetch and purge resources.

    • Both purge and prefetch tasks have daily quotas. For more information, see the sections about details on purge and prefetch operations below. If the daily bandwidth peak of your Alibaba Cloud account exceeds 200 Mbps, you can apply to increase the daily quota. Alibaba Cloud will assess and configure it according to your business needs.

    • When submitting cache purge or prefetch tasks, if your URI contains non-ASCII characters (such as spaces, Chinese characters, or special characters), you must encode the URL first. Otherwise, the content management system will not recognize the task. Please ensure that the URI you submit is in an encoded format.

Note

Purge or prefetch resources

Purge 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 the operation type as Refresh.

  4. Select the corresponding operation method: URL, Directory, or Regular Expression.

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

  6. Click Submit.

  7. Check the purge progress.

    Note

    If you have enabled auto CDN cache update in the OSS console, you cannot view the automatic purge tasks of OSS cache through the CDN console.

Operation method

Introduction

Precautions

URL

URL purge clears cache files that exactly match the URL. You need to enter the complete URL path of a single file, including protocol, domain name, path, and file. For example: https://www.example.com/static/picture/earth.jpg

  • To purge multiple URLs, enter one URL per line.

  • Each Alibaba Cloud account can submit up to 10,000 URL purge tasks per day.

Directory

Directory purge refreshes all files and subdirectories under the URL path you enter. You must enter the complete URL directory, ending with a slash (/). Include protocol, domain name, and path. For example: https://www.example.com/static/picture/

  • To purge multiple URL directories, enter one URL per line.

  • You can purge content from up to 100 directories at a time, and purge content from up to 100 directories for a domain name per minute.

  • Directory purge by default uses the "purge changed resources" method. If the Last-Modified information of the requested resource has not changed, the system returns the old cached information without going back to the origin. If you need to force purge the cache, see RefreshObjectCaches.

Regular Expression

Regular expression purge filters and purges resources using URLs with regular expressions. If a URL matches the regular expression you enter, it will be purged. For example: http://www.example.com/static/picture/[0-9][a-z].*.jpg

  • Each Alibaba Cloud account can submit up to 20 URLs containing regular expressions per day.

  • For more information about regular expression purge, see Configure URL purge rules that contain regular expressions.

  • Regular expression purge by default uses the "purge changed resources" method. If the Last-Modified information of the requested resource has not changed, the system returns the old cached information without going back to the origin. If you need to force purge the cache, see RefreshObjectCaches.

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 the operation type as Prefetch.

  4. Select URL as the operation method.

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

  6. Click Submit.

  7. Check the prefetch progress.

Operation method

Introduction

Precautions

URL

URL prefetch means prefetching a single file. You need to enter the complete URL path of a single file, including protocol, 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.

Automatically purge or prefetch resources

If you need to automate purge or prefetch operations, see Run scripts to purge and prefetch content.

Verify results

Verify purge or prefetch task results

  • Manual query

    View detailed records and progress of resource purge or prefetch on the Records tab. A progress of 100% indicates that the task is complete. If you have many prefetch or purge tasks, it may affect the completion progress. Please be patient.

    image

  • API query

    Call DescribeRefreshTaskById to check if a purge or prefetch task is complete. For more information, see DescribeRefreshTaskById.

Verify file prefetch task results

Run the following command to check the prefetch result of a file:

# Please replace this with your prefetched URL
curl -I 'http://oss.aliyundoc.com/1.png' 

The system displays the following result:

image

When X-Cache exists:

  • If X-Cache is HIT, the request has hit the cache, indicating a successful prefetch.

  • If X-Cache is MISS, the request did not hit the cache, suggesting that the prefetch task is incomplete or has failed. Please try prefetching again.

When X-Cache does not exist:

If X-Cache does not exist, it indicates that the resource has not been connected to Alibaba Cloud CDN. Please refer to Quick start to first connect the domain name of the URL to Alibaba Cloud CDN, and then prefetch the resource.

FAQ

Related API operations

You can call API operations to purge and prefetch resources. For more information, see Purge and prefetch API.