Configuration. Set up the CDN to follow origin redirects

About Redirection from Origin
Configuration
• via the control panel
• via the API

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 the content, so it is recommended that you purge the CDN cache when changes are made.

Configuration

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.

image1.png

2. In the navigation panel, under the Cache section, select Redirection from origin.

image2.png

3. Toggle Follow redirect from origin on.

image3.png

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

image4.png

5. Click Save changes. Allow at least 15 minutes for the changes to take effect.

image5.png

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:

"options": {
   "follow_origin_redirect": {
      "enabled": true,
      "codes": [
         302,
         308
       ]
    }
 }

Request properties

The follow_origin_redirect object passes the following information:

Property

Description

enabled

This property indicates whether to enable Redirection from Origin.

Possible values:

  • true enables the option
  • false disables the option

codes

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.

Possible values:

  • 301
  • 302
  • 303
  • 307
  • 308

Example

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.

image6.png

Was this article helpful?
Recently viewed articles