tencent cloud

DokumentasiTencent Cloud EdgeOne

CreatePurgeTask

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-25 17:00:05

1. API Description

Domain name for API request: teo.intl.tencentcloudapi.com.

When origin server resources update but the node cache TTL has not expired, users still access old resources. At this point, use this API to update node resources. The following two methods can trigger updates:

  • Direct deletion: Delete the node cache without any validation. User requests trigger origin-pull.
  • Mark expiration: Mark node resources as expired. User requests trigger back-to-origin validation, which sends HTTP conditional requests with If-None-Match and If-Modified-Since headers. If the origin server responds with 200, the node fetches new resources from the origin and updates the cache. If the origin server responds with 304, the cache will not be updated.
  • For details on purging cache tasks, see Purge Cache.

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    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 Zone ID.
    If you wish to quickly submit Targets Url under different sites, you can fill in *, but the account calling the API must have permission for all site resources under the root account.
    Type Yes String Node cache clearing type, with values:
  • purge_url: URL refresh;
  • purge_prefix: directory refresh;
  • purge_host: Hostname refresh;
  • purge_all: cache purge for all under the site (when this value is used, ZoneId input parameter * is not supported);
  • purge_cache_tag: cache-tag refresh.
  • For cache purge types, see Purge Cache.
    Method No String Node cache purge method, valid for directory refresh, Hostname refresh, and refresh all cache types. Valid values:
  • invalidate: refresh only resources that have been updated under the directory;
  • delete: refresh node resources regardless of whether resources under the directory are updated.
  • Default value: invalidate.
    Targets.N No Array of String List of resources for cache purging, for example, https://www.example.com/example.jpg. Protocol information must be included. The format of additional elements depends on the type of cache purging. Refer to the API call example below.
  • The number of tasks that can be submitted at a time is limited by the billing package quota. Check EO billing packages.
  • CacheTag No CacheTag This parameter is required when the node cache purge type is set to purge_cache_tag. The input value is a domain name.

    3. Output Parameters

    Parameter Name Type Description
    JobId String Task ID.
    FailedList Array of FailReason List of failed tasks and causes.
    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.

    4. Example

    Example1 URL Refresh

    This purge type uses the direct deletion purge method, which matches and purges the node cache resources of the submitted URL.
    For example, to purge the resource /a.txt under the site domain name www.example.com, refer to the following example to refresh.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.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"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwch",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    Example2 Hostname Update

    This purge type uses the expiration marking purge method, which will mark all resources under the submitted Hostname as expired.
    For example, to purge all resources belonging to the site domain name www.example.com that have undergone updates, refer to the following example to refresh.

  • Note: Host in the *.test.com format is not supported. The domain name cannot contain wildcard, and the corresponding subdomain is required.
  • Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreatePurgeTask
    <Common request parameters>
    
    {
        "Targets": [
            "www.example.com"
        ],
        "Type": "purge_host",
        "ZoneId": "zone-ajj243dwrew"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwcs",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    Example3 Cache-Tag Refresh

    This purge type uses the direct purge method, which will purge directly all resources belonging to the site that have the corresponding Cache-Tag response header tag value (tags) in HTTP responses.
    For example, to purge all resources belonging to site example.com whose HTTP responses contain tag1, tag2, or tag3, see the following example to refresh.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreatePurgeTask
    <Common request parameters>
    
    {
        "Targets": [
            "tag1",
            "tag2",
            "tag3"
        ],
        "Type": "purge_cache_tag",
        "ZoneId": "zone-ajj243dwrew"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwcs",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    Example4 Refresh all caches under the site

    This purge type uses the invalidation purging method, which will mark all cached content under the submitted site as expired.
    For example, to purge all resources belonging to site example.com that have been updated, see the following example to refresh.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreatePurgeTask
    <Common request parameters>
    
    {
        "Type": "purge_all",
        "ZoneId": "zone-ajj243dwrew"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwcs",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    Example5 Directory Refresh — Directly Delete Resources Under the Directory

    This clearing method requires the Method value to be changed to delete, which directly deletes node resources.
    For example, to purge all resources under the /test directory of the site domain name www.example.com, see the following example to refresh.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.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"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwck",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    Example6 Directory Refresh — Refresh Only the Resources with Modifications in the Directory

    This purge type uses the invalidation purge method by default. You can adjust the purge method based on Method.
    For example, to purge all changed resources under the /test directory of the site domain name www.example.com, see the following example to refresh.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.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"
    }

    Output Example

    {
        "Response": {
            "JobId": "20ga521cpwcj",
            "FailedList": [],
            "RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
        }
    }

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    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 Error in background processing.
    InternalError.DomainConfig Failed to get configuration.
    InternalError.ProxyServer Unknown error occurs on the real server.
    InternalError.QuotaSystem Quota system processing failure.
    InvalidParameter.DomainNotFound The domain name does not exist or does not belong to this account.
    InvalidParameter.ParameterError Parameter error: invalid "end time", not in the allowed query range: [start time, start + 7 days]
    InvalidParameter.Target The resource has an error.
    InvalidParameter.TaskNotGenerated Task unable to generate.
    InvalidParameter.UploadUrl The file upload link has an issue.
    LimitExceeded.BatchQuota Resource count in this submission exceeds the upper limit.
    LimitExceeded.DailyQuota Resource count submitted on the day exceeds the upper limit.
    LimitExceeded.PackNotAllow Billing package unsupported.
    UnauthorizedOperation.CamUnauthorized Unauthorized Cam operation.
    UnauthorizedOperation.NoPermission The sub-account does not have operation permissions. Add the required permissions and try again.
    UnauthorizedOperation.Unknown Unknown error occurs on the real server.

    Bantuan dan Dukungan

    Apakah halaman ini membantu?

    masukan