Setting up HTTP responses
A CDN resource can return a particular HTTP code and content instead of a standard response to all requests.
HTTP responses can be set up either globally or for a particular URI in location rules.
Setting up a redirect
-
In the management console
, select the folder where your resource is located. -
Go to Cloud CDN.
-
Click the resource name.
-
Navigate to the HTTP headers and methods tab.
-
In the top-right corner, click
Edit. -
Under Response settings, enable Custom HTTP response.
-
In the Response type field, select
Configure redirect. -
Specify a response code.
The following codes are supported:
301,302,303,307, and308. -
Specify a URL to redirect user requests to.
-
Click Save.
To enable the option, add the staticResponse section when using the create or update method for a Resource:
"staticResponse": {
"enabled": "<true_or_false>",
"code": "string",
"content": "string"
}
Where:
-
enabled: Enabling the option:trueenables the option.falsedisables the option.
-
code: Response code.The following codes are supported:
301,302,303,307, and308. -
content: Specify a URL to redirect user requests to.
To enable the option, add the static_response section when using the ResourceService/Create or ResourceService/Update call:
"static_response": {
"enabled": "<true_or_false>",
"code": "string",
"content": "string"
}
Where:
-
enabled: Enabling the option:trueenables the option.falsedisables the option.
-
code: Response code.The following codes are supported:
301,302,303,307, and308. -
content: Specify a URL to redirect user requests to.
It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend purging the resource cache.
Setting a response content
-
In the management console
, select the folder where your resource is located. -
Go to Cloud CDN.
-
Click the resource name.
-
Navigate to the HTTP headers and methods tab.
-
In the top-right corner, click
Edit. -
Under Response settings, enable Custom HTTP response.
-
In the Response type field, select
Set response content. -
Specify a response code.
Codes from the HTTP Status Code Registry
are supported, except for those havingUnassignedin the description. -
Specify JSON, HTML, or plain text you need to return to the client in the response body.
-
Click Save.
To enable the option, add the staticResponse section when using the create or update method for a Resource:
"staticResponse": {
"enabled": "<true_or_false>",
"code": "string",
"content": "string"
}
Where:
-
enabled: Enabling the option:trueenables the option.falsedisables the option.
-
code: Response code.Codes from the HTTP Status Code Registry
are supported, except for those havingUnassignedin the description. -
content: JSON, HTML, or plain text you need to return to the client in the response body.
To enable the option, add the static_response section when using the ResourceService/Create or ResourceService/Update call:
"static_response": {
"enabled": "<true_or_false>",
"code": "string",
"content": "string"
}
Where:
-
enabled: Enabling the option:trueenables the option.falsedisables the option.
-
code: Response code.Codes from the HTTP Status Code Registry
are supported, except for those havingUnassignedin the description. -
content: JSON, HTML, or plain text you need to return to the client in the response body.
It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend purging the resource cache.