Cache the Error Status Code

Last update:2024-07-01 16:40:40

Based on the HTTP error status codes returned from your origin server, you can perform simple custom settings on the CDNetworks CDN platform, to specify the cache duration of the error message page corresponding to those status codes on the CDN servers. This setting can help significantly reduce the load on your origin server by minimizing frequent back-to-origin requests when the CDN servers does not have a cached response to some malicious user requests. By default, CDN servers do not cache the error message pages returned by your website for error status codes.

How to Configure Error Status Code Caching

  1. Log in to the CDNetworks Console and select the appropriate product.
  2. Navigate to the Configuration, locate the domain you wish to configure, and click on Edit Configuration at the top or the Edit button to the right of the domain China Premium Service控制台自助配置功能上线.
  3. Enter the configuration modification page, find the Error Status Code Cache Duration under Cache Optimization, and click the Add button;
  4. On the rule editing page, you can easily add the following configuration options based on your needs.


The configurable items are as follows:

Parameter Description
Status Code Enter the origin response status code for which the CDN servers should cache the error message page. The platform supports the following status codes: 204; 305; 400; 403; 404; 405; 414; 416; 423; 429; 500; 501; 502; 503; 504.
Note: By default, the error message page for a 404 status code is cached for 1 minute.
Cache Time Configure the cache duration for the error message page corresponding to the above status codes on the CDN servers, currently supported time units are seconds,minutes and hours.
If the cache duration is set to 0, the page will not be cached on the CDN servers.

After you have completed setting the configurations, please click OK and then select Next to submit your settings. To minimize any potential disruptions to your production environment, we strongly recommend conducting a Pre-deploy test in a staging environment. This crucial step ensures that your configurations are accurate before they go live. Once you have verified the accuracy of the settings, click Deploy Now to implement them in the live environment. The configurations typically become effective within 3-5 minutes. For comprehensive guidance on pre-deployment testing and to verify the effectiveness of your configurations, please consult the tutorial Deploy the Configurations to Staging Environment for Validation.

Best Practices

Example 1: Configuring Cache Duration for Error Message Page with Origin Response Status Code 403 or 404
For the associated accelerated domain with this rule, when a user request triggers a response with status code 403 or 404 from the origin server via the CDN, the error message page will be cached on the CDN servers for 10 minutes. During this cache duration, if another user makes a similar request, the CDN node will directly return the cached error message page.


Notes

If you configure a long cache duration for the error message page on the CDN servers, the CDN servers will return the cached page directly to your users within that cache period. Therefore, exercise caution when setting the cache duration in the rules if you intend to return a different specific file to clients within a shorter timeframe.

Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!