About Redirection from Origin
The Redirection from Origin option controls whether the CDN follows redirects returned by the origin. By default, this option is disabled, which means that when the origin returns an HTTP 3xx status code, the CDN simply caches and serves this response to the user. If you enable this option, the CDN automatically retrieves the target content from the new location, which is then cached and returned to the user.
Important: Setting redirects may cause users to receive an outdated version of content, so it is recommended that you purge the CDN cache when changes are made.
Via the control panel
To configure origin redirection using the control panel:
1. Go to CDN and select the CDN resource you want to configure.
2. In the navigation panel, under the Cache section, select Redirection from origin.
3. Toggle Follow redirect from origin on.
4. Select one or more status codes in the Redirect status codes select box. The options are:
- 301—to follow redirect for status code HTTP 301
- 302—selected by default; follows redirect for status code HTTP 302
- 303—to follow redirect for status code HTTP 303
- 307—to follow redirect for status code HTTP 307
- 308—to follow redirect for status code HTTP 308
5. Click Save changes. Allow at least 15 minutes for the changes to take effect.
Important: Once saved, we recommend purging the CDN cache to ensure that users receive an updated version of your content.
Via the API
To configure origin redirection using the API, the request must include the follow_origin_redirect object. The following is a sample code for the object:
The follow_origin_redirect object passes the following information:
This property indicates whether to enable Redirection from Origin.
This property is an array of HTTP status codes that will cause the CDN to follow a redirect. The array must contain a minimum of 1 and a maximum of 5 items.
This example shows a CDN update request that activates the Redirection from Origin and instructs the CDN to follow redirects for status codes 301, 302, and 303.