Purge instantly removes specified content from the CDN cache, forcing a retrieval of the latest version from your origin. Use this to ensure immediate content updates, apply configuration changes, or remove non-compliant materials without waiting for the cache to expire. Prefetch proactively loads your resources onto the CDN before peak traffic hits. This protects your origin server from overload and guarantees a fast, cached response for even the first wave of users during launches or high-demand events.
How purge and prefetch work
Resource purge
A purge operation sends a cache invalidation command to CDN POPs, rather than directly deleting files. When a POP receives the command, it marks the matching cached resources as "invalid" or "expired." The next time a user requests the resource, the POP detects the invalid cache, retrieves the latest version from the origin server, and serves it to the user while re-caching it.
Use cases
Update and release content: After updating resources on your origin server, purge their URLs or directories. This ensures users receive the latest versions instead of stale content.
Remove non-compliant content: If you delete non-compliant content from your origin server, it might still be accessible from the CDN cache. Use the URL purge feature to clear the cache and ensure the content is completely removed.
Resource prefetch
Prefetching prompts CDN POPs to retrieve resources from your origin server based on a provided URL list and cache them. This process differs from the origin server actively pushing content. Prefetching improves the first-visit loading speed for new resources or promotional pages and reduces back-to-origin traffic during high-traffic events, protecting your origin server.
Use cases
Onboard Alibaba Cloud CDN: When you first start using Alibaba Cloud CDN, prefetch your popular static resources to the POPs. This improves initial access speed and enhances user experience.
Support promotional campaigns: Before launching a major promotional campaign, prefetch all static resources for the campaign pages to the CDN POPs. When the campaign begins, the POPs directly serve all user requests for these resources, ensuring fast page loads.
Publish installation packages or large files: Before releasing a new software version or update package, prefetch the resources to the CDN POPs. After the official launch, the POPs directly handle user download requests, which accelerates download speeds and reduces the load on your origin server.
Before you start
Permissions: If you use a RAM user, grant the
cdn:PushObjectCache(for prefetch) andcdn:purgeObjectCaches(for purge) permissions. For more information, see Authorize a RAM user to prefetch and purge resources.URL format: URLs with non-ASCII characters (like Chinese characters or spaces) must be
UTF-8percent-encoded.
Notes
Timing: Purge and prefetch tasks generate origin fetch traffic. We recommend that you perform large-scale tasks during off-peak hours.
Shared cache: If a domain uses a shared cache, a purge task on the primary or any associated domain invalidates the cache for all of them.
Rewrite URL: if the access URL for the domain name has been rewritten, POP uses the rewritten URL to generate a Cachekey, therefore use the rewritten URL for a purge or prefetch task.
Billing
The purge and prefetch features are free of charge.
However, both operations trigger CDN POPs to fetch resources from your origin server. This generates origin traffic and requests, which incurs fees. The billing standards depend on your origin server type:
If your origin server is Alibaba Cloud Object Storage Service (OSS), you are billed for the outbound traffic over the Internet and the number of requests with HTTP status codes 2xx and 3xx returned.
If your origin server is an Alibaba Cloud Elastic Compute Service (ECS) instance or another server, you are billed based on its network bandwidth or traffic.
Large-scale purge or prefetch operations, especially within a short period, can increase origin fetch costs. Evaluate the potential cost impact before you proceed.
Procedure
Purge resources
Log on to the CDN console.
In the navigation pane on the left, click Purge and Prefetch.
On the Purge/Prefetch tab, select Purge as the operation type.
Select a purge method and submit the task.
Purge method
Instructions
By URL
Purpose: Invalidates the cache for one or more specific files.
Procedure: In the Purge Content input box, enter the full URLs, including
http://orhttps://, with one URL per line. For example:https://www.example.com/static/image.jpg.By directory
Purpose: Invalidates the cache for all content within a directory.
Procedure: Enter the full directory URL, which must end with a forward slash (
/). Example:https://www.example.com/static/.Note: This method performs a cache revalidation. To perform a forced purge on the entire directory, use the RefreshObjectCaches and set
Force=true.By regular expression
Purpose: To batch invalidate cached resources by matching URL paths with a regular expression.
Procedure: Enter a URL that contains a regular expression. For example,
https://www.example.com/static/[0-9][a-z].*.jpgImportant: Use precise matching rules to avoid unintended, large-scale cache invalidation.
Note: This method performs a cache revalidation. To perform a forced purge on the entire directory, use the RefreshObjectCaches and set
Force=true.Click Submit. The system then starts the task.
NoteYou cannot cancel a purge task after it is submitted.
A purge task typically takes 5 to 6 minutes to take effect. If the cache expiration time for your resources is shorter than this duration, manual purging is not necessary.
If you enable auto CDN cache update in the OSS console, you cannot view the auto cache update tasks for OSS in the CDN/ console.
Prefetch resources
Log on to the CDN console.
In the navigation pane on the left, click Purge and Prefetch.
On the Purge/Prefetch tab, select Prefetch as the operation type.
In the Prefetch Content text box, enter the full URLs of the files that you want to prefetch, one per line. For example,
https://www.example.com/install/package.zip. Prefetching folders is not supported.Click Submit. The system then starts to run the prefetch task.
NoteYou cannot cancel a prefetch task after it is submitted.
A prefetch task typically takes 5 to 30 minutes to complete, depending on the file size, number of files, and origin server performance.
Automated purge or prefetch
We recommend using automated purge and prefetch scripts for the following situations:
You manually submit tasks, resulting in high operational costs.
You have many URLs to process, which makes manual batch submission inefficient.
You need to monitor task status, which is time-consuming.
Verify results
Verify manually
On the Records tab, you can view the detailed records and progress of your purge or prefetch tasks. A progress of 100% indicates task completion. Tasks with a large number of resources may take longer to complete.

Verify by API
Call the DescribeRefreshTaskById API to check whether a purge or prefetch task is complete.
Verify by command line
Run the
curl -I <resource_URL>command. The system displays the following result:
If the
X-Cacheheader is in the response:If
X-CacheisHIT, the request hit the cache, and the prefetch was successful.If
X-CacheisMISS, the request did not hit the cache. The prefetch task is not complete or has failed. Prefetch the resource again.
If the
X-Cacheheader is not in the response:The resource is not accelerated by CDN. Add the domain name of the URL to Alibaba Cloud CDN and then prefetch the resource. For more information, see Get started with Alibaba Cloud CDN.
Quotas
Operation | Method | Quota | Manage or increase quotas |
Purge | By URL | Up to 10,000 URLs per day per account | |
By directory |
| ||
By regular expression | Up to 20 expressions per day per account | ||
Prefetch | By URL |
|
Reference: CDN cache purge mechanisms
Alibaba Cloud CDN provides two cache purge mechanisms, revalidation and forced purge, for different scenarios to help you manage cached content with flexibility and efficiency.
Revalidation (default CDN policy)
Use cases: Routine content updates, such as releasing new versions of static files.
Mechanism: Purging by directory or regular expression in the console use this behavior by default. When a CDN POP retrieves a resource from the origin, it includes the
If-Modified-SinceorIf-None-Matchrequest header. The origin server uses these headers to validate if the resource has been updated.Result: If the resource on the origin server has not changed, the origin server returns a
304 Not Modifiedstatus code. The CDN POP continues to serve the old cached copy, which consumes no origin fetch traffic. This optimized method saves costs and reduces the load on your origin server.
Forced purge
Use cases: Urgent removal of non-compliant or incorrect resources, or scenarios where you need to force a network-wide update after fixing an incorrect
Cache-Controlheader configuration.Mechanism: To trigger a Forced Purge, call RefreshObjectCaches and set the
Forceparameter totrue. Then the CDN POP unconditionally marks the cached resource as invalid.Result: When the resource is next requested, the POP must retrieve a new version from the origin, even if the origin file is unchanged.