After you enable this feature, /DCDN POPs handle 301/302 responses directly. This reduces client round trips and accelerates resource delivery.
Prerequisites
301/302 redirection is used on the origin server.
The permissions to configure 301/302 redirection have been obtained. By default, this is unavailable to external users. To request permissions, submit a ticket.
Background information
The HTTP status codes 301 and 302 indicate that a resource has moved. In this case, the server typically includes a Location header in the response. When a client receives a 301/302 response with a Location header, it redirects to the address specified in the Location header to request the resource.
How it works
If a POP redirects a request to an origin server and receives HTTP status code 301 or 302 from the origin server, the POP processes the status code. The request is redirected to the address that is specified by the Location header returned from the origin server to retrieve the resource. In this case, HTTP status code 301 or 302 is not returned to the client.
A user requests the file
http://example.com/examplefile.txt.The file is not cached on the /DCDN POP, which triggers a back-to-origin request.
The origin server returns a 301/302 status code, with the Location header set to
http://www.example.org/examplefile.txt.After receiving the response from the origin server, the /DCDN POP sends a request to the Location address
http://www.example.org/examplefile.txtto fetch the resource.After a DCDN POP retrieves the required resources, it caches them on the DCDN POP.
The /DCDN POP returns the fetched resource to the client.
If other users request http://example.com/examplefile.txt, the requested file is served directly from the POP.
Usage notes
Before you configure 301/302 redirection for a domain name, check whether an origin host is configured for the domain name. For more information, see Configure the default origin host.
If an origin host is not configured for the domain name: When the origin server returns HTTP status code 301 or 302 and the Location header that specifies a URL to the POP, the request is redirected to the URL that is specified by the Location header. The value of the Host header in the request is the domain name that is specified by the Location header.
If an origin host is configured for the domain name: When the origin server returns HTTP status code 301 or 302 and the Location header that specifies a URL to the POP, the value of the Host header in the request is the Host header that is configured for the accelerated domain name. By default, the Host header value is the accelerated domain name. If you use the domain name that is specified by the Location header as the value of the Host header in the origin request, an error occurs. If you want DCDN to support this scenario, submit a ticket.
The Location header that is returned from the origin server can be in the following formats:
Location:
http://www.example.net/index.html. The POP redirects the request to the full URL specified by the Location header.Location:
//www.example.net/index.html. The POP redirects the request to the URL that includes the protocol that the original request uses and the value of the Location header.Location:
/index.html. The POP redirects the request to the URL that includes the protocol and domain name that the original request uses and the value of the Location header.
Procedure
-
Log on to the DCDN console.
-
In the left-side navigation pane, click Domain Names.
-
On the Domain Names page, find the domain name that you want to manage and click Configure.
-
In the left-side navigation tree of the domain name, click Origin Fetch.
On the Origin Fetch tab, find 301/302 Redirection.
Turn on the 301/302 Redirection switch.
Click Modify and configure the parameters according to the following table.
Parameter
Description
Maximum Number of Redirects
Specify the maximum number of times that a POP can redirect to the URL that is specified by the Location header for each request. If the maximum value is exceeded, HTTP status code 301 or 302 is returned to the user. Valid values: 1 to 5. Default value: 2.
NoteThe maximum number of 301/302 redirects determines the number of origin requests that can be redirected to the origin server by a POP.
Maximum number of origin requests = Maximum number of 301/302 redirects + 1. In this case, the default maximum number of origin requests is 3. Valid values: 2 to 6.
Retention Request Parameters
Yes: In 301/302 redirects, the parameters in requests that are redirected to the origin server are retained. The request parameters are passed to the server specified by the Location header.
No: In 301/302 redirects, the parameters in requests that are redirected to the origin server are not retained.
Retain Request Headers
Yes: In 301/302 redirects, the headers in requests that are redirected to the origin server are retained. The header parameters are passed to the server specified by the Location header.
No: In 301/302 redirects, the headers in requests that are redirected to the origin server are not retained.
Click OK.