Updated on 2024-05-16 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

Task ID.

task_type

String

Type of a task. The value is either refresh or preheating.

status

String

Task result. task_done indicates that the preheating task succeeded.

task_inprocess indicates that the task is being preheated.

processing

Integer

Number of URLs being processed.

succeed

Integer

Number of URLs processed.

failed

Integer

Number of URLs that failed to be processed.

total

Integer

Total number of tasks.

create_time

Integer

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

URLs that need to be prefetched.

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 Codes

See Status Codes.

Error Codes

See Error Codes.