Skip to content

Cache Configuration

Configuration Scenario

Cloud Protection's cached resources are trigger-based. When a user accesses a resource, if the requested node does not have the resource cached, it will fetch the resource from the origin server. Upon successfully retrieving the resource (with a 2XX status code), the node caches the resource and returns it to the user.
You cannot directly manage the resources cached on Cloud Protection nodes. If you are concerned that the origin server resources may have changed while the Cloud Protection nodes still return outdated cached resources, you can configure node caching rules to exercise some control.
Each cached resource on a Cloud Protection node has a concept of "expiration time." If a cached resource has expired, even if the node still holds the cache, it will be deemed invalid, and the node will fetch the resource again from the origin. Node caching rules allow you to specify the expiration time for cached resources of certain types, directories, or paths on the nodes, which can be configured according to your actual business needs.

Configuration Guide

View Configuration

Log in to Cloud Protection, select ​​Domain Management​​ from the menu bar, click ​​Configure​​ next to the domain name, and navigate to the domain configuration page. Under the second section, ​​Cache Configuration​​, you can view the cache expiration settings.
When adding an accelerated domain: By default, no file types are cached.

img

Modify Configuration

  1. Modify Configuration

Cloud Protection currently supports the following three types of cache expiration rule configurations:

  • ​File Type​​: Set the cache expiration time based on the file extensions entered. The format is .jpg, and multiple extensions are separated by ;.
  • ​Directory​​: Set the cache expiration time based on the directory path entered. The format is /test, and it does not need to end with /. Multiple directories are separated by ;.
  • ​Full Path File​​: Specify the complete file path to set the cache expiration time. The format is /index.html.

img

Configuration Rules:

  • A maximum of 10 cache expiration rules can be configured.
  • Multiple cache expiration rules follow a "first-match" priority.
  • The maximum cache expiration time is 365 days.

  • Platform Policy

When a user requests a resource from your business, if the HTTP Response Header from the origin server contains a Cache-Control field, the default platform policy is as follows:

  • If the Cache-Control field is Max-Age, the cache time for the resource is determined by the configured node cache expiration time and does not inherit the time specified by Max-Age.
  • If the Cache-Control field is no-cache, no-store, or private, the Cloud Protection node will not cache this resource.

Configuration Example

If the cache expiration rules for the accelerated domain www.test.com are configured as follows:

img

The actual cache times are as follows:

  1. File types jpg;png have a node cache expiration time of 7 days.
  2. The directory /test/ has a node cache expiration time of 1 day.
  3. The path /index.html has a node cache expiration time of 10 minutes.