Content Delivery Network (CDN) allows you to create status code expiration rules to expire static resources of specified file types or in specified directories. When a status code expires, the relevant static resource is deleted from the edge node. This topic describes how to create a status code expiration rule.

Background information

When you create a status code expiration rule, note the following limits:
  • The system does not cache status codes 303, 304, 401, 407, 600, and 601.
  • If the origin returns a Cache-Control header, status codes 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, and 504 are cached according to the amount of time specified by the Cache-Control header. If no status code expiration rule is created, these status codes are cached according to the amount of time specified by negative_ttl (1 second by default).
  • If you have created two status code expiration rules for static resources of specified file types and in specified directories, whichever created first takes effect.

Procedure

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Domain Names page, find the target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain, click Cache.
  5. Click Status Code Expiration.
  6. In the Create Expiration Rule dialog box, select Directory or File Extension, enter directories or file extensions, and enter status code and caching time pairs.
    • Create a status code expiration rule for static resources of specified file types or in specified directories.
      1. Click Create Rule.
      2. Select a static resource type: Directory or File Extension.
        Resource type Description
        Directory
        • Enter a directory, which can be a full path. The directory must start with a forward slash (/), such as /directory/aaa.
        • Status codes 2xx and 3xx are not cached.
        File Extension
        • Enter one or more file extensions. Separate multiple file extensions with commas (,), for example, txt,jpg.
        • Asterisks (*) cannot be used as wildcard characters to match all file types.
        • Status codes 2xx and 3xx are not cached.
        Status Code Expiration Rule
      3. Click OK to add the expiration rule.

        You can click Modify or Delete in the Actions column to modify or delete a rule.

    • Create a status code expiration rule that prioritizes the origin cache policy.
      1. Click Create Rule.
      2. Enter status code and caching time pairs.Status Code Expiration
      3. Click OK.

        You can click Modify or Delete in the Actions column to modify or delete a rule.