Alibaba Cloud Content Delivery Network (CDN) allows you to create cache expiration rules to expire static resources of specified file types or in specified directories. You can also specify a priority for each cache expiration rule. When a static resource expires, the resource is automatically deleted from the CDN node that caches the resource. This topic describes the rules that are used to expire cached resources on a CDN node and how to create a cache expiration rule.
Background information
When you update a resource file on the origin server, we recommend that you include the version number in the name of the update file instead of using the same name as the existing resource file. For example, you can name two update files img-v1.0.jpg and img-v2.1.jpg. Then, you can set a cache expiration rule for the resource file.

- If you have not set a cache expiration time on your origin server or CDN nodes, the CDN nodes use the default TTL value of 3,600 seconds to expire cached resources. After you add a domain name to Alibaba Cloud CDN, you can modify the TTL value. The amount of back-to-origin traffic and fees vary based on the TTL value. We recommend that you set a TTL value based on your business requirements. A small TTL value may cause CDN nodes to frequently redirect requests to the origin server and increase the amount of network traffic consumed by the origin server.
- If an origin server has a caching rule configured, the cache expiration rule on the CDN node has a higher priority than the caching rule that is configured on the origin server. If an origin server has no caching rule configured, you can set a cache expiration rule by directory or by file extension. You can set a full-path cache expiration rule.
- A CDN node may remove the cached files before they expire if they are not frequently updated.
- If the response from an origin server contains the ETag header, the request from a client contains the If-Match header, and the value of the If-Match header matches the value of the ETag header, the CDN node that is closest to the client returns the cached content to the client. If the value of the If-Match header does not match the value of the ETag header, the CDN node retrieves the latest content from the origin server and returns it to the client. At the same time, the CDN node updates the cached content with the latest content. The matching rule between the If-Match header and the ETag header has a higher priority than the cache expiration rule that is configured on CDN nodes.