Cache policy configuration

Last Updated: Nov 26, 2017

Introduction

  • 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.

Note:

  • 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, img-v1.0.jpg and img-v2.1.jpg.

Operation procedure

  1. Log on to the CDN console

  2. On the left-side navigation pane, click Domain Names.

  3. Select a domain to enter the management page and find Cache setting:

44

For example, set three cache policies for the CDN domain example.aliyun.com.

  • 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.

The priority is Policy 1 > Policy 3 > Policy 2.

Note:

  • 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.

Thank you! We've received your feedback.