Updated on 2024-05-16 GMT+08:00

Creating a Cache Refreshing Task

Function

This API is used to create a cache refreshing task.

URI

POST /v1.0/cdn/refreshtasks

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 parameters

Parameter

Mandatory

Type

Description

type

No

String

Type of cached content to be purged. The value is either file or directory. The default value is file.

urls

Yes

Array of strings

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

Example request

Requested path

POST https://cdn.myhuaweicloud.com/v1.0/cdn/refreshtasks?enterprise_project_id=0
{
    "refreshTask":{
        "type":"file",
        "urls":[
            "http://www.example.com/index.html",
            "http://www.example.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

Task type. The value is either refresh or preheating.

status

String

Task result. task_done indicates that the refreshing task succeeded.

task_inprocess indicates that the refreshing task is being processed.

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 purged.

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

Status Codes

See Status Codes.

Error Codes

See Error Codes.