Configure the Cache Expiration Time
Cache configuration refers to a set of expiration and elimination rules that CDN nodes follow when caching resources. Configuring the cache expiration time is to configure the duration that the cache file will be kept in the cache. CDN cached resources have a certain expiration time; before the resource expires, the node responds to the request received; when the resource expires, the node requests the origin server to re-cache and sends the resource to the user.
When accessing the domain name, the console automatically Configure Default Cache for it and the user can edit weight value to adjust the priority of the rules taking effect. Cache contents include:
- The global static files are cached for 30 days by default, with a weight of 2.
- The cache time of the dynamic files, such as .php, .jsp, .asp and others, is 0 by default, with a weight of 3.
- Cache control weight in the origin server HTTP Header is 1.
The expiration time can be set via Console, and also set via Cache Control Header in HTTP Header (Expires or Cache-control).
- When you do not set it, CDN does not cache data.
- When setting both, judge the priority according to the configured cache strategy weight.
Differences of setting cache control header Expires and Cache-control in HTTP Header:
- Cache-control： It is used to control http cache. If it sets to be "no-cache", it means that the indicating requests or response messages cannot be cached (HTTP/1.0 is replaced with no-cache of Pragma).
- Expires： It indicates the failure item, which is also the cache time of the file on local client, equivalent to the effect of max-age, and the Expires value shall be the time of GMT format: Such as Thu, 01 Dec 1994 16:00:00 GMT.
If Expires and Cache-control coexist at the same time, Expires will be overwritten by max-age of Cache-Control.
- Verification failed or the domain name which is being verified cannot be configured.
- CDN supports you to configure the expiration time by yourself. The cache setting of the CDN console is of higher priority than the setting of HTTP Header of the origin server. If you want the priority of the origin server to be higher than that of the console setting, you can modify the weight of the corresponding rule to achieve it.
- The user can set the expiration time for at most 15 configuration items.
- Suggest setting the expiration time of static content such as jpg, png and mp3 to one month.
- It is not recommended to configure the same weight for two cache strategies, and if the weight is same, one of the strategies will be selected randomly to take effect.
Two default characteristics of the cache configuration:
- For any user request, if the current resource is not expired, the node responds, and if the current resource expires, request the origin server to cache and respond to the request.
- If you do not configure any cache rule, it sets the expiration time of cached resources according to the response header of the origin server.
Configure Cache Expiration Time in the Console
1.Log into the CDN Management Console and enter the “Content Delivery Network (CDN)" page.
2.Click Domain Name Management on the left navigation bar.
3.Enter the domain name management page, and click the Management of the target domain name operation column.
4.Enter the “CDN Domain Name Details" page, and select the Cache Configuration tab in the navigation bar at the top of the page.
5.Click Add Configurations in the module of Cache Expiration Time Configuration.
6.Click Add Configurations, and configure the following parameters in the pop-up "Add Cache Setup Page".
|Type||Support to configure the file extension, directory, status code and accurate file. |
|Cache item||Specify which specific resources are applicable to the cache configuration.|
|Expiration time||Overdue time of resources on nodes Expiration time of status code cache is 0-120 s, and the expiration time configured shall be within this range. Set the expiration time to 0, that is, do not cache the content.|
|Weight||Weight represents the priority of cache rules, and the value range is 0-100. The higher the weight, the higher the priority, and the corresponding rule takes precedence. Rules with the same weight take effect randomly.|
7.Click Confirm to complete adding the cache expiry time of a configuration item.
8.After completion of addition, view it on the page of Cache Expiration Time Configuration, and Edit/Delete the expiration time of such configuration in the operation column of configuration item.