No Caching Based on Response Headers

Last update:2024-07-17 17:19:57

If you want the CDNetworks CDN platform not to cache file resources containing certain response headers, you can achieve this through a few simple configurations. With this custom setup, when an incoming user request triggers a response containing the specified headers, the CDN nodes will bypass the cache, fetch the file resources directly from your origin server, and return them to the user. On subsequent requests for the same file, the CDN node will again request the file from the origin server and return it to the user without caching it. Currently, you can configure the CDN nodes not to cache files with the Location or Set-Cookie response headers.

How to No Caching Based On Response Headers

  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 image.png.
  3. Enter the configuration modification page, find the No Cache Based on Cache-control Header under Cache Optimization. On the right of the page, check Location or Set-Cookie based on your requirement under the Response Header field.
Parameter Description
Location By default, CDN servers do not cache contents with a 302 status code from your origin server, unless an expiration header like Expires or Cache-Control: max-age is also present.
For 301 status codes, CDN servers cache contents unless a no-cache header is returned by the origin server or a custom non-caching rule is set as described in the Set Cache Rules.
If you select the Location response header for non-caching, CDN servers will bypass caching for contents with the Location header from your origin, regardless of whether the status code is 301 or 302.
Set-Cookie If Set-Cookie is selected, any contents returned by your origin server with a Set-Cookie header will not be cached by 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.

Notes

When you configure CDN platform to request contents from your origin server and your origin server responds with specific headers, those files will not be cached by the CDN servers, this means that all such user requests will trigger a fetch from your origin server, potentially increasing the load on your origin.

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!