Domain name for API request: teo.tencentcloudapi.com.
When there are resources updated on the origin with the TTL remaining valid, users cannot access the latest resources. In this case, you can purge the cache using this API. There are two methods:
A maximum of 20 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: CreatePurgeTask. |
Version | Yes | String | Common Params. The value used for this API: 2022-09-01. |
Region | No | String | Common Params. This parameter is not required. |
ZoneId | Yes | String | ID of the site. |
Type | Yes | String | Type of cache purging. Values:purge_url : Purge by the URLpurge_prefix : Purge by the directorypurge_host : Purge by the hostnamepurge_all : Purge all cachespurge_cache_tag : Purge by the cache-tag |
Method | No | String | Node cache purge method, valid for directory, hostname, and all cache refreshes. Valid values: |
Targets.N | No | Array of String | List of resources for which cache is to be purged. Each element format depends on the cache purge type and you can refer to the API examples for details. |
CacheTag | No | CacheTag | The information attached when the node cache purge type is set to purge_cache_tag. |
Parameter Name | Type | Description |
---|---|---|
JobId | String | ID of the task. |
FailedList | Array of FailReason | List of failed tasks and reasons. Note: This field may return null, indicating that no valid values can be obtained. |
RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
By using Delete method, resources under a URL that matches the specified hostname are removed.
This example shows you how to purge resources in the directory /a.txt under the site domain www.example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Targets": [
"http://www.example.com/a.txt"
],
"Type": "purge_url",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwch",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
By using Invalidate method, resources under a domain name that matches the specified hostname are marked as invalid.
This example shows you how to purge resources changed under the site domain www.example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Targets": [
"www.example.com"
],
"Type": "purge_host",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwcs",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
By using Invalidate method, resources under a site are associated with tags in the HTTP response header Cache-Tag and marked as invalid.
This example shows you how to purge resources that contain tag1, tag2 and tag3 and have changed under the site example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Targets": [
"tag1",
"tag2",
"tag3"
],
"Type": "purge_cache_tag",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwcs",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
By using Invalidate method, all cached resources under a site are marked as invalid.
This example shows you how to purge all cached resources changed under the site example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Type": "purge_all",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwcs",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
To purge all resources under a directory, pass delete
into the Method field.
This example shows you how to purge all resources in the /test directory under www.example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Targets": [
"http://www.example.com/test/"
],
"Type": "purge_prefix",
"Method": "delete",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwck",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
To purge the resources updated under a directory, pass invalidate
into the Method field.
This example shows you how to purge resources changed in the directory /test under the site domain www.example.com.
POST / HTTP/1.1
Host: teo.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreatePurgeTask
<Common request parameters>
{
"Targets": [
"http://www.example.com/test/"
],
"Type": "purge_prefix",
"Method": "invalidate",
"ZoneId": "zone-ajj243dwrew"
}
{
"Response": {
"JobId": "20ga521cpwcj",
"FailedList": [],
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
InternalError.BackendError | Server error. |
InternalError.DomainConfig | Failed to get configuration |
InternalError.ProxyServer | An unknown error occurred in the backend server. |
InternalError.QuotaSystem | Server error. |
InvalidParameter.DomainNotFound | The domain name does not exist or is not belong to this account. |
InvalidParameter.ParameterError | Parameter error: Invalid “End time”. The interval between the start and end time cannot exceed 7 days. |
InvalidParameter.Target | Resource error |
InvalidParameter.TaskNotGenerated | Failed to create the task |
InvalidParameter.UploadUrl | Invalid file upload link. |
LimitExceeded.BatchQuota | Reached the upper limit of resource number |
LimitExceeded.DailyQuota | Reached the daily upper limit of resource number |
LimitExceeded.PackNotAllow | Not supported by the plan. |
UnauthorizedOperation.CamUnauthorized | CAM is not authorized. |
UnauthorizedOperation.NoPermission | The sub-account is not authorized for the operation. Please get permissions first. |
UnauthorizedOperation.Unknown | An unknown error occurred in the backend server. |
Was this page helpful?