Set HTTP Header
The HTTP header setup feature allows you to custom or add the header information of optional CDN nodes to response (HTTP response header) of the client and of CDN nodes to request of origin server (HTTP request header).
When the customer's website is accessed to CDN, as the client and origin server will process relevant behavior according to the field information of the HTTP header, so the customer has the need to modify the HTTP header. Baidu AI Cloud CDN supports to modify the header information in the response (HTTP response header) of the client, request from CDN node to origin server (HTTP request header).
HTTP message consists of the requests from client to server and responses from server to client.
- Every domain can configure the information of 20 HTTP headers at most.
- It is expected that the configuration, modification or deletion of HTTP header will take effect in 10 minutes, after which you can see the new configuration results.
- The maximum length of the HTTP header value is 160, which contains English characters, numbers, and special characters.
- The maximum length of the HTTP header description is 100, which is in the UTF-8 format and contains Chinese characters, numbers and special characters.
- The field accept-encoding in user's request header can be used to set the static files output by CDN, with gzip compression feature.
Commonly Used HTTP Response Header
The commonly used response header of HTTP is shown as follows:
|Cache-Control||Specify the cache mechanism that the browser request and response shall follow|
|Expires||Specify the expiration time of the browser response object|
|Content－Type||Specify the content type of browser response object|
|Content-Disposition||Activate the custom resource download settings and the default file name when downloading|
|Content-Language||Assign the response language of the resource in the client (such as the browser)|
|Access-Control-Allow-Origin||Specify the source of request that are allowed to access resources in terms of cross-domain request|
|Access-Control-Allow-Methods||Specify the allowable cross-domain request methods in terms of cross-domain request|
|Access-Control-Max-Age||The cache time of the returned pre-request result for the specific resource when assigning a cross-domain request|
|Access-Control-Expose-Headers||Specify custom header information that allows access.|
Set HTTP Header
1.Log in CDN Management Console, select Domain Name Management from the Navbar on the left of the console.
2.On the Domain Name Management page, select the domain name that needs to set HTTP header, and click Management in the action bar to the far right, as shown in the figure below.
3.On the Domain Name Details page, click Advanced Configuration, as shown in the figure below.
4.Click Add HTTP Header at Custom HTTP Header Configuration on Advanced Configuration page.
|Type||You can select node to end where the response takes effect HTTP response header, select node to origin server where the request takes effect Set up HTTP request header.|
|HTTP header||Besides supporting setting , customized HTTP header is also supported to input.|
|Value||You need to set the value corresponding to the HTTP header, case sensitive. E.g.: The HTTP header is set as Content-Language, and you can set the corresponding value as zn-CN.|
|Description||You can add description for HTTP header, so as to facilitate the recording and management of HTTP header.|
- The resource will be forwarded to origin when the node is not hit, and the header information returned by the origin server will be returned to the user altogether.
- Since the HTTP response header configuration focuses on domain name, the user can add the configured header in any resource response message under the domain name once the configuration takes effect.
- Configuring HTTP response header only affects the response behavior of the client, and does not affect the caching behavior of the CDN node.
5.Click OK after completing the configuration.
6.You can click Edit or Delete in the HTTP header list to have operations on the HTTP header currently configured.
After the HTTP header is configured in the console, the http header parameters configured are carried in the returned code of request or access using the current domain name. For example, set the common HTTP header parameter as follows: Content-Language is English, and expires at 20, and the results are shown as follows when using curl request:
Request example(Take www.baidu.com as an example)
> GET / HTTP/1.1 > Host: www.baidu.com > User-Agent: curl/7.43.0 > Accept: */*
< HTTP/1.1 200 OK < Server: bfe/18.104.22.168 < Date: Thu, 23 Mar 2017 08:31:37 GMT < Content-Type: text/html < Content-Length: 2381 < Last-Modified: Mon, 23 Jan 2017 13:27:30 GMT < Connection: Keep-Alive < ETag: "588604c2-94d" < Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform < Pragma: no-cache < Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/ < Accept-Ranges: bytes < Content-Language: english < Expires: 20
You can see the setting parameters with HTTP in the last two lines of the return example.
- You can, through Set up HttpHeader Interface set the Http Header for specified acceleration domain name.
- You can, through Query HttpHeader Interface query the Http Header for specified acceleration domain name.