API
The Gcore Customer Portal is being updated. Screenshots may not show the current version.
CDN
CDN
BillingCDN resources overviewOrigin groupPurgePrefetchReports
API
Chosen image
Home/CDN/CDN resource options/Cache/Set a redirect from an origin

Set up a CDN resource to follow origin redirects

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.

CDN resource

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

Cache section

3. Toggle Follow redirect from origin on.

Follow redirect from origin

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
Redirect status codes

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

Save changes

Note: 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.

CDN update request

Was this article helpful?

Not a Gcore user yet?

Learn more about our next-gen CDN

Go to the product page