Updated on 2022-09-28 GMT+08:00

Creating a Cache Preheating Task

Function

This API is used to create a cache preheating task.

URI

POST /v1.0/cdn/preheatingtasks

Table 1 lists the parameters.

Table 1 Parameter description

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Enterprise project to which the cache refreshing task is added. This parameter is valid only when the enterprise project function is enabled. The value all indicates all projects. This parameter is mandatory when you use an IAM user to call this API.

Request

Request parameters

Table 2 describes the request parameters.

Table 2 Request parameter

Parameter

Mandatory

Type

Description

urls

Yes

Array of strings

Value example: http://abc.com/image/1.png. Use commas (,) to separate URLs from each other. Preheating for directories is not available yet. A single URL can contain a maximum of 10,240 characters. 1,000 URLs can be entered at a time.

Example request

Requested path

POST https://cdn.myhuaweicloud.com/v1.0/cdn/preheatingtasks?enterprise_project_id=0
{
    "preheatingTask":{
        "urls":[
            "http://www.example1.com/index.html",
            "http://www.example2.com/web"
            ]
        }
}

Response

Response parameters

Table 3 describes the response parameters.

Table 3 Response parameters

Parameter

Type

Description

id

String

Specifies the task ID.

task_type

String

Specifies the type of a task. The value is either refresh or preheating.

status

String

Specifies the status of a preheating task. task_done indicates that the preheating task succeeded.

task_inprocess indicates that the task is being preheated.

processing

Integer

Specifies the number of URLs being processed.

succeed

Integer

Specifies the number of URLs processed successfully.

failed

Integer

Specifies the number of URLs that failed to be processed.

total

Integer

Specifies the total number of tasks.

create_time

Integer

Specifies the time when the task is created, which is expressed as milliseconds since 1970-01-01 00:00:00 Coordinated Universal Time (UTC).

urls

Array of strings

Specifies URLs that need to be preheated.

Example response
{
  "preheatingTask" : {
    "id" : "ff8080*********************c6e",
    "status" : "task_inprocess",
    "processing" : 2,
    "succeed" : 0,
    "failed" : 0,
    "urls" : [ "http://www.example1.com/index.html", "http://www.example2.com/web" ],
    "task_type" : "preheating",
    "total" : 2,
    "create_time" : 0
  }
}

Status Code

See Status Codes.

Error Code

See Error Codes.