Dynamic Route for CDN (DCDN) determines whether resource requests are responded in a normal manner based on HTTP status codes. To reduce workloads on origin servers and enable DCDN nodes to directly return non-2xx HTTP status codes, you can create time-to-live (TTL) rules for HTTP status codes. This allows static resources of specified file types or in specified directories to expire based on HTTP status codes. After the resources expire, they are automatically deleted from DCDN nodes.

Background information

2xx HTTP status codes indicate that DCDN nodes have obtained requested resources from origin servers. In normal cases, when an origin server returns a 2xx HTTP status code, the DCDN node processes the resources based on the configured DCDN cache expiration rules. In some cases, the origin server cannot return non-2xx HTTP status codes in a short period of time and you do not want all requests to be passed through to the origin server. In such cases, you can set TTL rules for HTTP status codes. This way, the DCDN node can directly return non-2xx HTTP status codes to reduce the workloads on the origin server.

The following HTTP status codes are supported:
  • 4xx: 400, 401, 403, 404, 405, 407, and 414
  • 5xx: 500, 501, 502, 503, 504, 509, and 514
Note
  • DCDN does not cache the following HTTP status codes: 303, 304, 401, 407, 600, and 601.
  • If Cache-Control is set on the origin server, DCDN caches the HTTP status codes 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, and 504 based on the Cache-Control rule of the origin server. However, if no TTL is set for these HTTP status codes, the default TTL is 1 second.

Procedure

  1. Log on to the DCDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Configure page, find the domain name that you want to manage and click Domain Names in the Actions column.
  4. In the left-side navigation pane on the details page of the specified domain name, click Caching.
  5. Click the Status Codes and Expiration Time tab.
  6. Click Add.
  7. Set a TTL rule for HTTP status codes based on file types or directories as prompted.
    Note If you specify a status code TTL for both resources of specified file types and resources in specified directories, the rule that is first created takes precedence.
    Status code expiration rule
    Parameter Description
    Type Directory and File Extension are supported. Select a type based on your actual needs.
    Object
    • If you specify Directory as the type, enter the information based on the following instructions:
      • You can add only one directory at a time.
      • You can enter the full path of a directory. The path must start with a forward slash (/). For example, you can enter /www.abc.com/path.
    • If you specify File Extension as the type, enter the information based on the following instructions:
      • You can enter one or more file extensions. Separate multiple file extensions with commas (,). For example, you can enter JPG,TXT.
      • You cannot use an asterisk (*) to match all file types.
    HTTP Status Codes and Expiration Time You can configure TTL settings for HTTP status codes based on the following requirements:
    • You can specify TTL values for the 4xx and 5xx HTTP status codes. Separate multiple TTL settings with commas (,) and specify the TTL in seconds. For example, you can enter 403=10,404=15.
    • The value to the left side of the equal sign cannot be 2xx or 3xx. You can specify TTL values only for specific 2xx or 3xx HTTP status codes, such as 201 and 302.
  8. Click OK.
    In the Status Codes and Expiration Time list, find the created TTL rule, and click Modify or Delete to perform corresponding operations.