ApsaraVideo VOD lets you configure the validity period for status codes of static resources in specific directories or with specific filename extensions. This way, CDN nodes directly return HTTP status codes to requests, and the loads on the origin server are reduced. This topic describes how to configure the validity period for status codes.
Scenario
Normally, the origin server returns an HTTP 2xx status code to the CDN nodes if CDN nodes have retrieved the requested resources from the origin server. Then, the CDN nodes process the requests based on cache expiration rules. If the origin server fails to return an HTTP 2xx status code to the CDN nodes, and you do not want the origin server to respond to every request, you can configure a validity period for HTTP status codes. This way, CDN nodes directly return HTTP status codes to requests, and the loads on the origin server are reduced.
CDN does not cache the following status codes: 303, 304, 401, 407, 600, and 601.
For the following status codes, if the origin server includes a Cache-Control header in the response, CDN adheres to the directives in the header: 204, 305, 400, 403, 404, 405, 414, 500, 501, 502, 503, and 504. If you do not configure an expiration time for these status codes, the default cache duration is 1 second.
Procedure
Log on to the ApsaraVideo VOD console.
In the navigation pane on the left, choose Configuration Management > CDN Configuration > Domain Names.
Find the domain name that you want to configure and click Configure.
In the navigation pane on the left for the specified domain name, click Cache.
Click the Validity Period tab.
Click Add to configure a status code expiration rule.

Type
Notes
Type
The supported types are Folder and File Extension. Select a type based on your actual requirements.
NoteIf you configure expiration times for status codes for both a directory and a file name extension, ApsaraVideo VOD matches rules based on the order in which they were configured. The rule that was configured first takes precedence. After a rule takes effect, no other rules are matched.
Address
If you select Folder as the type, note the following:
Add only one directory at a time.
Enter the full path of the directory. The path must start with a forward slash (/). Example: /directory/aaa.
If you select File Extension as the type, note the following:
Enter one or more file name extensions. Separate multiple extensions with commas (,). Example:
JPG,TXT.You cannot use an asterisk (*) to match all file types.
Status Code Validity Settings
The unit is seconds. Separate multiple status codes with commas (,).
You can set an expiration time for a class of status codes using a fuzzy match, such as 4xx or 5xx. Example: 4xx=10,5xx=15.
You cannot use a fuzzy match for 2xx and 3xx status codes. You can set an expiration time only for specific status codes. Example: 201=10,302=15.
Click OK to complete the configuration.
After the configuration is complete, you can find the rule in the Validity Period list. You can then Modify or Deleted the rule.