- 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).
- CDN cached files can be removed from the CDN node if the cached files are not updated frequently.
- For infrequently updated static files (e.g. image files or application download files), we suggest you set a cache time of 1 month or more;
- For static files that must be updated or are updated frequently (e.g. js and css files), you can set a shorter cache time based on the actual situation;
- For dynamic files (for example, PHP files, JSP files, and ASP files), we recommend that you set the cache duration as 0s, indicating that the files are not cached. If dynamic files such as PHP files are not updated frequently, we recommend that that you set the cache duration to a small value.
- We recommend that the content on an origin site is updated with the same file name, but tagged with different version numbers; for example, img-v1.0.jpg and img-v2.1.jpg.
- Go to CDN Domain Names page, select a domain name to enter the Domain Names page and find Cache setting:
- Click Modify, you can manage cache policies by perform adding, modifying and deletion operations.
- Click Add to add cache policies by directory paths or filename suffixes.
For example, set three cache policies for the CDN domain name
- Cache policy 1: the cache duration for all files suffixed with .jpg and .png is one month, and the weight is 90.
- Cache policy 2: the cache duration for files in the /www/dir/aaa directory is one hour, and the weight is 70.
- Cache policy 3: the cache duration for the full path /www/dir/aaa/example.php is 0 s (No cache action will be performed), and the weight is 80.