Creating a Cache Refreshing or Preheating Task
Description
This section describes how to create a cache refreshing or preheating task using APIs. For details about how to call APIs, see Calling APIs.
Involved APIs
- If you use token-based authentication, obtain a token and add X-Auth-Token to the request header when calling an API.
- Creating a Cache Preheating Task: Preheats origin server content to CDN nodes.
- Creating a Cache Refreshing Task: Refreshes cached content on CDN nodes.
Procedure
- Obtain a user token and use it for authentication when calling the API for creating a cache preheating or refreshing task. For details, see Making an API Request.
- To obtain the username and domain name, log in to the Huawei Cloud management console, point to the account name in the upper right corner, and choose My Credentials from the drop-down list.
- Request URL: POST https://iam.myhuaweicloud.com/v3/auth/tokens
- Request header: Content-Type: application/json
- Request body:
{ "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": "name", --Username "password": "password", --Password "domain": { "name": "domainname" --Name of the account to which the user belongs } } } }, "scope": { "domain": { "name": "domainname" --Name of the account to which the user belongs } } } }
Information in the red box in the following figure indicates the obtained user token.

- Create a cache preheating task.
- Select the POST request method and enter the request URI.
POST https://cdn.myhuaweicloud.com/v1.0/cdn/content/preheating-tasks
- Add X-Auth-Token to the request header.
- Specify the following parameters in the request body:
{ "preheating_task": { "urls": [ "https://www.bxxx/1.txt", "https://www.bxxx/2.txt" ] } } - Example response:
{ "preheating_task": "7620240" } - If the request fails, an error code and error information are returned. For details, see Error Codes.
- Select the POST request method and enter the request URI.
- Create a cache refreshing task.
- Select the POST request method and enter the request URI.
POST https://cdn.myhuaweicloud.com/v1.0/cdn/content/refresh-tasks
- Add X-Auth-Token to the request header.
- Specify the following parameters in the request body:
{ "refresh_task": { "type": "file", "urls": [ "https://www.bxxx/1.txt", "https://www.bxxx/2.txt" ] } } - Example response:
{ "refresh_task": "7620242" } - If the request fails, an error code and error information are returned. For details, see Error Codes.
- Select the POST request method and enter the request URI.
Last Article: Adding an Acceleration Domain Name
Next Article: Permissions Policies and Supported Actions
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.