The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

<Node Cache Expiration Configuration>

Last updated: 2026-05-12 09:39:20
The node cache configuration allows you to set the cache expiration time of origin server resources on CDN nodes, adjusting the cache update frequency. You can configure the cache expiration time of resources by directory, file suffix name, or full file path according to your business needs.

Feature Introduction

CDN determines whether the cached resources on CDN nodes have expired based on the cache expiration time set in the node cache configuration.
If the resource accessed by the user is not expired in the CDN node cache, the CDN node returns the cached resource directly to the user.
If the resource accessed by the user is not cached or the cache has expired, the CDN node will pull the latest resource from the origin server, cache it on the CDN node, and return it to the user.
After a resource on the origin server is updated, its cache on the CDN node must be updated immediately. You can use the Purge Cache feature to update unexpired caches on the CDN node, ensuring consistency between the resources cached on the CDN node and those stored on the origin server.

Notes

The cache validity period will affect the back-to-origin frequency. It is recommended to set the resource cache duration based on actual business needs. If the cache validity period is too short, CDN will frequently pull the content from the origin server, increasing the origin server's bandwidth. If it is too long, the cache will be updated slowly, affecting users' access to the latest resources.
CDN nodes cache resources according to Tencent Cloud CDN Caching Rules and Priorities. However, the cached resources on CDN nodes may be deleted before the cache validity period expires due to request frequency too low.
It is recommended to use different names for resources before and after updating the origin server, such as naming resources with version numbers (img-v1.jpg, img-v2.jpg) to avoid CDN nodes returning old resources to users due to unexpired cache after the origin server updates the resource content.
If you are still using the old version (basic mode) of the node cache validity configuration, it is recommended to upgrade to the latest version by configuring and submitting in advanced mode to support more features. Note that once upgraded to advanced mode, it cannot be reverted to the original basic mode. View the old version of the node cache validity configuration document: Node Cache Validity Configuration (Old).
The origin server can control the cache validity period of CDN nodes by setting the response header Cache-Control (cache option: follow origin server). At the same time, CDN nodes will pass the Cache-Control response header to users to control the browser's cache time. If you need CDN nodes to set the browser's cache time, you can modify the Cache-Control header returned to users by CDN nodes through Browser Cache Validity Configuration.

Configuration Instructions

Directions

1. Log in to the CDN Console.
2. Click Domain Management in the left menu to enter the domain management list;
3. Select the domain to configure and click Management to enter the domain configuration page;
4. Click Cache Configuration, switch to the cache configuration tab, where you can view the Node Cache Configuration.;


5. Click Adding rules to enter the new rule page and add node cache configuration.



Configuration Item
Description
Type
Supports configuration for all files, file suffix, file directory, full path file, and homepage: All files: Set rules for all files, default rule. File suffix: Set rules for file suffix. File directory: Set rules for file directory. Full path file: Set rules for full file path. Homepage: Set rules for domain root directory.
Content
Based on the selected file type, content input constraints: When the type is all files: Fixed as all files. When the type is file suffix: Supports input of file suffix name, separated by ";". For example, jpg;png;css. When the type is file directory: Supports input of file directory, not ending with "/", separated by ";". For example, /test;/a/b/c. When the type is full path file: Supports input of full file path, separated by ";". For example, /index.html;/test/.jpg. Note: Content is case-sensitive, please enter the correct case.
Cache options
Supports configuration according to follow origin server, cache, and no cache rules: Follow origin server: Set CDN node cache time according to the origin server response header Cache-Control, supports setting heuristic cache. Cache: Custom set CDN node cache time, supports setting forced cache. No cache: Set CDN node to not cache resources.

Tencent Cloud CDN Cache Rules and Priorities

Cache option is: follow origin server




CDN nodes will follow the origin server response header Cache-Control to set cache time
The origin server response header Cache-Control field is max-age, set CDN node cache time according to the max-age value, such as Cache-Control: max-age=300, then the cache time is 300 seconds;
The origin server response header Cache-Control field has both max-age and s-maxage, set CDN node cache time according to the s-maxage value, such as Cache-Control: max-age=300 s-maxage=600, then the cache time is 600 seconds;
The origin server response header Cache-Control field is no-cache or no-store or private, CDN nodes do not cache resources;
When the origin server's response header lacks Cache-Control or Expires, cache rules are set according to heuristic caching, as follows:
Disable heuristic caching: when the origin server's response header lacks Cache-Control or Expires, the cache duration is 0 seconds.
Enable heuristic caching: when the origin server's response header lacks Cache-Control or Expires, heuristic cache duration is set according to the following rules: i. Automatically configured: If the origin server's response header includes Last-Modified, then cache duration = (current time - Last-Modified) * 0.1. If Last-Modified is absent, the default cache duration is 600 seconds.



ii. Custom policy: Allows for custom setting of heuristic cache duration.




Caching options: Caching




Customize the cache time of CDN nodes.
Disable forced caching:
If the origin server's response header Cache-Control field is max-age or both max-age and s-maxage are present, cache according to the custom CDN node caching rules.
If the origin server's response header lacks Cache-Control or Expires, cache according to the custom CDN node caching rules.
If the origin server's response header Cache-Control field is no-cache, no-store, or private, CDN nodes do not cache the resource.


Enable forced caching: Ignore the origin server's response header Cache-Control and cache according to the custom CDN node caching rules.



The cache option is: Do not cache

Set CDN nodes to not cache resources. For each user request for this resource, CDN nodes will directly retrieve the resource from the origin server and respond to the user.



Priority of multiple cache rules

When configuring multiple cache rules simultaneously, the larger the priority weight number, the higher the priority (the bottom rule has higher priority than the top rule). You can adjust the priority by clicking adjust priority and dragging the order of cache rules.



Recommended Configuration

Infrequently updated static files (e.g., image types, application download types, etc.) are recommended to be set to 30 days.
Frequently updated static files (e.g., js, css) should have their cache time set according to the business update frequency.
Dynamic files (e.g., php, jsp, asp, aspx) should be set to do not cache.
Other requests involving site log-in (e.g., WordPress backend log-in directory /wp-admin) or API queries that need to interact directly with the origin server should be set to do not cache, otherwise, it may cause access errors.

Configuration limitations

A maximum of 100 caching rules can be added for a single domain name.
Priority of multiple caching rules: rules at the bottom have higher priority than those at the top.
In a single file suffix/file directory/full path file rule, up to 100 entries can be input, separated by ";". For example: file suffix jpg;png.
If you have not configured any rules or the request does not match the configured rules, the CDN node will follow the Cache-Control header settings from the origin server to determine the cache time. If the origin server response header does not have a Cache-Control field, the CDN node will cache the resource for 600 seconds by default.
CDN nodes only cache the content of GET and HEAD request types. For other request types such as POST and OPTIONS, CDN nodes do not cache the content.

Configuration Example

Sample 1

The original cache rule was: resources with php, jsp, asp, and aspx file extensions are not cached, while all other files are cached for 30 days.

Now, it is required to add: resources with jpg and png file extensions are cached for 10 days, and the origin server response header Cache-Control is ignored, i.e., forced caching is enabled. The cache rule for all other files is modified to follow the origin server.
1. Click Add Rule, set the type to file suffix, the content to jpg;png, the cache option to cache, the cache time to 10 days, and enable forced caching. Click Yes.


2. Select the cache rule for all files, click Modify, change the cache option to follow the origin server, and click Yes.


3. The cache rules after the adjustment are:
Resources with jpg,png file extensions are cached for 10 days with forced caching;
Resources with php;jsp;asp;aspx file extensions are not cached;
All other files follow the origin server for caching.

The actual caching situation is as follows:
www.test.com/abc.jpg The resource node cache time is 10 days, even if the origin server response header Cache-Control field is no-cache, no-store, or private.
www.test.com/def.php The resource will not be cached to the node;

Sample 2

Recommended node cache validity configuration for WordPress sites:
Resources under the backend login address /wp-admin directory need to be set to no-cache, otherwise, backend login-related resources will be cached, causing login errors. If there are other API-related resources, they also need to be set to no-cache.
Resources with dynamic file extensions such as php, jsp, asp, and aspx need to be set to no-cache (default CDN caching rules).
html;js;css file extensions are updated frequently, and the cache time should be set according to the update frequency. It is recommended to set the cache time to 7 days without setting forced cache;
30 days for all other files (CDN default cache rule).
Based on the default CDN cache rules, add new rules as follows:
1. Click add new rule, type is directory, content is /wp-admin, cache option is no-cache, click Yes.


2. Click add new rule, type is file extension, content is html;js;css, cache option is cache, cache time is 7 days, forced cache is no, click Yes.


3. According to the priority order, bottom priority higher than top, click adjust priority, drag the "/wp-admin directory no-cache rule" to the bottom to make this rule the highest priority.

4. The adjusted cache rules are:
All resources under the /wp-admin directory are not cached;
Resources with html;js;css file extensions are cached for 7 days;
Resources with php;jsp;asp;aspx file extensions are not cached;
30 days for all other files.



FAQs