Resource cache in Tencent Cloud CDN is triggered by requests. When a user initiates an access request to a resource, if the CDN node receiving the request has not cached the requested resource, it will forward the request to the origin server to pull the resource. After the resource is successfully pulled by the node (with a 2XX status code returned), it will be cached on the node and returned to the user.
You cannot directly manage resources cached on CDN nodes. If you are worried that resources on the origin server change but CDN nodes still cache the legacy resources and return them to users, you can configure node cache rules.
Each cached resource on CDN node has an expiration time. If the requested cached resource has expired, it will be considered as invalid even if the resource is still cached on the node. The node will pull the resource from the origin server again. Node cache rule allows you to configure the cache validity period for resources in a specific type, directory, and path. You can configure these items based on actual business scenarios.
Log in to the CDN Console, select Domain Management on the left sidebar, and click Manage on the right of the domain name to enter its configuration page. Under the Cache Configuration tab, find the cache validity configuration.
When you connect an acceleration domain name:
CDN currently allows you to configure cache validity rules in the following four formats:
;, such as
/testand does not need to end with
/. Different directories should be separated with
/index.html. The full file path and file type can be combined for match, such as
If your acceleration domain name is configured for global acceleration, the configured cache validity period will take effect globally. This configuration does not distinguish between requests from and outside of the Chinese mainland.
When a user makes a request for a certain business resource and the origin server's HTTP response header includes the
Cache-Control field, the default policy will be as follows:
Max-Age, the cache validity period for this resource is subject to that configured for the node, rather than the value specified by
private, the CDN node will not cache the resource.
Cache-Controlfield does not exist, when the request hits the CDN cache, CDN will add the "Cache-Control:max-age = 600" header by default.
After advanced cache configuration is enabled, you can adjust the node cache validity period dynamically by configuring the
Max-Age value in the HTTP response header
Cache-Control of the origin server.
After advanced cache configuration is enabled, CDN will compare the configured node cache validity period with the
Max-Age value and take the smaller one as the actual validity period.
/index.htmlof the origin server is 200 seconds and the cache validity period configured for CDN is 600 seconds, the actual cache validity period of the file will be 200 seconds.
/index.htmlof the origin server is 800 seconds and the cache validity period configured for CDN is 600 seconds, the actual cache validity period of the file will be 600 seconds.
After advanced cache configuration is enabled, if the origin server does not return the
Last-Modifiedfield, CDN will add it by default and change its value once every 10 minutes.
Suppose the cache validity rule configured for the acceleration domain name
cloud.tencent.com is as follows:
The actual cache validity period will be as follows: