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 |
|
Prefetch |
|
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.
-
-
For more information about refresh and prefetch precautions and issues, see FAQ about Refresh and Prefetch.
-
If you experience slow access after configuring CDN, it is recommended to troubleshoot the issue using the suggested document before updating resources with the refresh feature. For more information, see Troubleshoot Slow Website Access after Using Alibaba Cloud CDN Acceleration.
-
For website access issues, see Troubleshoot Inaccessible or Abnormal Access Issues.
Refresh or prefetch resources
Refresh resources
Log on to the Alibaba Cloud CDN console.
-
In the left-side navigation pane, click Purge and Prefetch.
-
On the Purge/Prefetch tab, select Refresh as the operation type.
-
Select the appropriate operation method: URL, Directory, or Regex.
-
Enter or upload the data to be processed in the URL field.
-
Click Submit.
-
View the refresh progress.
NoteIf 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 |
|
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/ |
|
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 |
|
Prefetch resources
Log on to the Alibaba Cloud CDN console.
-
In the left-side navigation pane, click Purge and Prefetch.
-
On the Purge/Prefetch tab, select Prefetch as the operation type.
-
Select the appropriate URL for the operation method.
-
Enter or upload the data to be processed in the URL field.
-
Click Submit.
-
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 |
|
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.
-
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:
If the X-Cache
header is present:
-
If
X-Cache
showsHIT
, this means the request successfully hit the cache and the prefetch was effective. -
If
X-Cache
showsMISS
, 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.