This function can be used to set the actions of a cache server against resources in different directory paths, or resources with different filename suffixes. You can customize cache expiration rules for specified resources.
You can customize a cache policy priority.
The following figure shows the default cache policies.
This function is used to set file expiration time. The priority specified here is higher than that configured on the origin site. If no cache policy is configured on the origin site, you can set a cache policy by directory and filename suffix (the full path mode is supported).
For static files that are not updated frequently (for example, image files and application download files), it is suggested that the cache duration be set to one month or longer.
For static files that need to be updated frequently (for example, JS files and CSS files), you can reduce the cache duration based on service conditions.
For dynamic files (for example, PHP files, JSP files, and ASP files), it is suggested that the cache duration be set to 0s, indicating that the files will not be cached. If dynamic files such as PHP files are not updated frequently, it is suggested that the cache duration be set to a small value.
It is recommended that the content on an origin site is updated with the same file name, but tagged with different version numbers; for example,
Log on to the
On the left-side navigation pane, click CDN Domain Name List.
Select a domain to enter the management page.
On the left navigation bar, click Cache Configuration.
Click Add Cache Configuration.
For example, set three cache policies for the CDN domain
- Cache policy 1: the cache duration for all files suffixed with
.pngis one month, and the weight is 90.
- Cache policy 2: the cache duration for files in the
/www/dir/aaadirectory is one hour, and the weight is 70.
- Cache policy 3: the cache duration for the full path
/www/dir/aaa/example.phpis 0 s (No cache action will be performed), and the weight is 80.
The priority is Policy 1 > Policy 3 > Policy 2.
The range of weight is from 1 to 99. The larger the number, the higher the priority.
It is recommended that you do not set the same weights for different cache policies. Cache policies with the same weight will be assigned a random weight value.