Cache validity configuration refers to a set of expiration policies the CDN cache nodes should follow when caching your business contents.
All resources cached on CDN nodes have an expiration time. For unexpired resources, when a request reaches the node, the node will directly return the requested resource to the user, so as to speed up the resource acquisition. For expired resources, the node will forward the user request to the origin server to reacquire the resource, and then cache it to the node and return it to the user at the same time. A reasonable cache validity period can effectively improve the resource hit rate and lower the origin-pull rate, reducing bandwidth usage.
Cache-Controlfield with a value of
max-age=xxxx, the cache validity period for the resource on the node will be the smaller one among the set validity period and the
max-ageset for the
/index.htmlof the origin server is 200 seconds and the cache validity period set for CDN is 600 seconds, the actual cache validity period for the file will be 200 seconds.
max-ageset for the
/index.htmlof the origin server is 800 seconds and the cache validity period set for CDN is 600 seconds, the actual cache validity period for the file will be 600 seconds.
Cache-Controlfield does not exist in the response header of your origin server, CDN adds the
Cache-Control: max-age=600header by default.
You can configure browser cache validity in the CDN console. For more information, please see Browser Cache Validity Configuration.
Please see the directions in Node Cache Validity Configuration (Legacy).
You can configure different cache validity periods for different types of directories and files. If the cache validity period is configured to 0, the CDN node will not cache the resource, in which case the CDN node needs to pull related resources from the origin server every time the users send access requests to the node. For more information on cache configurations, please see Node Cache Validity Configuration (Legacy).
Tencent Cloud CDN supports cache validity configurations at various dimensions, custom priority adjustment, and cache inheritance policies (advanced cache validity configuration). A reasonable cache validity period can effectively improve the resource hit rate and lower origin-pull rate, reducing bandwidth usage.
The default configuration is as follows when a domain name is connected:
When a user makes a request for a certain business resource, the origin server's response HTTP header includes the
Cache-Control field. The default policy is as follows:
max-age, the cache validity period for this resource will be the period set for the resource, and will not inherit the value specified by
no-store, the CDN node will not cache the resource.
When multiple caching policies are set, the priorities of the entries are determined on a bottom-to-top basis, with the entry at the bottom of list having the highest priority and the one at the top having the lowest priority. For example, suppose the following caching policies are set for a domain name:
All files (30 days) .php .jsp .aspx 0 seconds .jpg .png .gif 300 seconds /test/*.jpg 400 seconds /test/abc.jpg 200 seconds
If the domain name is
www.test.com, and the resource is
www.test.com/test/abc.jpg, the matching rule will be as follows:
The final cache validity period is subject to the last matching result, and so it will be 200 seconds.