This topic describes how to set a time-to-live (TTL) value for HTTP status codes that are returned to requests for static resources in a specified directory or with specified file extensions. This allows CDN edge nodes to directly return HTTP status codes to requests and reduces loads on origin servers.


HTTP 2xx status codes indicate that CDN edge nodes have retrieved the requested resources from the origin server. In this case, the origin server returns an HTTP 2xx status code to the CDN edge nodes. Then, the CDN edge nodes process the requests based on cache expiration rules. If the origin server fails to return HTTP status codes, such as an HTTP 2xx status code, to the CDN edge nodes, and you do not want the origin server to respond to every request, you can set a TTL value for HTTP status codes. Then, CDN edge nodes directly return HTTP status codes to requests to reduce loads on the origin server.

  • HTTP 303, 304, 401, 407, 600, and 601 status codes are not supported.
  • If the Cache-Control header is configured on the origin server, Alibaba Cloud CDN caches the following HTTP status codes based on the Cache-Control directive: 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, and 504. If you do not set a TTL value for these HTTP status codes, the TTL value is set to 1 second by default.


  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 domain name that you want to manage and click Manage in the Actions column of the domain name.
  4. In the management pane of the domain name, click Cache.
  5. Click the Status Code Expiration tab.
  6. Click Create Rule to create an expiration rule for HTTP status codes.
    Create an expiration rule for HTTP status codes
    Parameter Description
    Type You can select Directory or File Extension. Select a type based on your business requirements.
    Note If you set TTL values for the HTTP status codes of both a directory and files with specified extensions, whichever rule that is set first takes effect. All other rules are ignored.
    • If you select Directory, take note of the following rules:
      • You can add only one directory in each rule.
      • You can enter a full path. It must start with a forward slash (/), for example, /directory/aaa.
    • If you select File Extension, take note of the following rules:
      • You can enter one or more file extensions. Separate file extensions with commas (,), for example, JPG,TXT.
      • You cannot use an asterisk (*) to specify all file types.
    Expire In
    • You can set a TTL value for 4xx and 5xx HTTP status codes. The TTL value is in seconds. Separate HTTP status codes with commas (,), for example, 4xx=10,5xx=15.
    • You cannot set a TTL value for 2xx or 3xx status codes. You can set a TTL value only for specific HTTP status codes, including 201 and 302 status codes. The TTL value is measured in seconds. For example, you can set 201=10,302=15.
  7. Click OK.

    After an expiration rule for HTTP status codes is created, it is displayed on the Expire In tab. You can Modify or Delete the rule.

Related API operations