Setting the Cache TTL
CDN caches origin content on globally distributed PoPs so that users can obtain the content from nearby PoPs. On the CDN console, you can set the cache TTL for origin content of different file types based on service requirements.
Impact of Origin Servers on CDN PoP Caches
- If you have configured a cache rule on the origin server, the following scenarios are possible:
- If you have set Cache-Control to no-cache, private, or no-store on the origin server and enabled Origin Cache Control on the CDN console, CDN PoPs do not cache origin content. Instead, CDN PoPs pull content from the origin server each time the content is requested. This does not achieve acceleration.
By default, Origin Cache Control is disabled on the CDN console.
- If you have set a specific TTL on the origin server, this TTL will be overwritten by that set on the CDN console.
- If you have set Cache-Control to no-cache, private, or no-store on the origin server and enabled Origin Cache Control on the CDN console, CDN PoPs do not cache origin content. Instead, CDN PoPs pull content from the origin server each time the content is requested. This does not achieve acceleration.
- If no cache rules are set on the origin server, cache rules set on the CDN console are used.
Setting a Cache TTL Based on Service Type
Default cache TTL
- If the service type is website acceleration, file download acceleration, or on-demand service acceleration, and the origin server address is an IP address or domain name, the following default cache rules are available:
- The default cache TTL for common dynamic files (for example, .php, .jsp, .asp, and .aspx files) is 0. CDN pulls content from the origin server directly when receiving requests for such dynamic files. You can modify and delete this rule.
- The default cache TTL for other files is 30 days. You can modify but cannot delete this rule.
- If your origin server is an OBS bucket, the default cache TTL for all files is 30 days. You can modify but cannot delete this rule.
You can add a custom cache rule with a higher priority so that custom rule will be used.
- If the service type is whole site acceleration, a cache rule with Type set to All files and Maximum Age set to 0 is available by default. You can modify and delete this rule.
You can configure a cache TTL based on the service type and the following suggestions.
- Website acceleration
- Do not cache dynamic files such as .php, .aspx, .asp, .jsp, .do, .dwr, .cgi, .fcgi, .action, .ashx, .axd, and .json files.
- Cache .shtml, .html, .htm, and .js files for seven days.
- Cache other static files for 30 days.
- Download acceleration
- Do not cache dynamic files such as php, aspx, asp, jsp, and .do files.
- Cache files of the following types for 30 days: .7z, .apk, .wdf, .cab, .dhp, .exe, .flv, .gz, .ipa, .iso, .mpk, .mpq, .pbcv, .pxl, .qnp, .r00, .rar, .xy, .xy2, .zip, and .cab.
- On-demand service acceleration
- Do not cache dynamic files such as .php, .aspx, .asp, .jsp, and .do files.
- Cache the following file types for seven days: .mwv, .html, .htm, .shtml, .hml, .gif, .swf, .png, .bmp, and .js.
- Cache the following file types for 30 days: .mp3, .wma, .7z, .apk, .wdf, .cab, .dhp, .exe, .flv, .gz, .ipa, .iso, .mpk, .mpq, .pbcv, .pxl, .qnp, .r00, .rar, .xy, .xy2, .zip, and .cab.
Procedure
- Log in to Huawei Cloud console. Choose .
The CDN console is displayed.
- In the navigation pane, choose .
- In the domain list, click the target domain name or click Configure in the Operation column.
- Click the Cache Settings tab.
- In the Cache Rules area, click Edit.
The Configure Cache Rule dialog box is displayed.
- Click Add to add cache rules. Table 1 describes the parameters.
Figure 1 Configuring a cache rule
- (Optional) Delete a cache rule if you no long use it.
- Click OK.
If you have modified a cache rule,
- Your modifications are effective for new content cached.
- You can purge to apply modifications to the existing cache.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.