Updated on 2024-12-10 GMT+08:00

Redirect from Origin

Background

If an origin server uses a 301/302 redirect, when a CDN PoP sends a request to pull content requested by a user from the origin server, a 301/302 status code is returned. CDN then takes action based on whether redirect from origin is enabled.

  • Disabled

    The CDN PoP returns the redirect address to the user and leaves the user to finish the request process. If the domain name of the redirect address is not added to CDN, the subsequent request process will not be accelerated by CDN.

  • Enabled

    The CDN PoP pulls content from the redirect address and caches the content, which is then returned to the user. When another user requests the same content, the cache is returned directly.

Precautions

If the service type of your domain name is whole site acceleration, this function takes effect only for static resources.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Origin Settings tab.
  5. In the Redirect from Origin area, switch on or off Redirect from Origin.
    Figure 1 Configuring redirect from origin

Examples

  • Assume that redirect from origin is enabled for domain name www.example.com.

    If a user requests the www.example.com/cdn.jpg file and the CDN PoP does not cache the content, the PoP pulls the content from the origin server. The origin server returns the HTTP status code 301 or 302 and the redirect address www.example.com/test/cdn.jpg.
    1. The PoP directly sends a request to the redirect address.
    2. After obtaining the requested content, the PoP returns the content to the user and caches the content.
    3. When another user requests the same file, the PoP directly returns the cached content.
  • Assume that redirect from origin is disabled for domain name www.example.com.

    If a user requests the www.example.com/cdn.jpg file and the CDN PoP does not cache the content, the PoP pulls the content from the origin server. The origin server returns the HTTP status code 301 or 302 and the redirect address www.example.com/test/cdn.jpg.
    1. The PoP directly returns the HTTP status code 301 or 302 to the user client. The user client sends a request to the redirect address.
    2. If the domain name of the redirect address is not added to CDN, CDN PoPs do not cache the requested content and the subsequent request process will not be accelerated.
    3. If another user requests the same file, the preceding process is repeated.