tencent cloud

Tencent Cloud EdgeOne

Release Notes and Announcements
Release Notes
Security Announcement
Announcements
Product Introduction
Overview
Strengths
Use Cases
Comparison Between EdgeOne and CDN Products
Use Limits
Purchase Guide
Description of Trial Plan Experience Benefits
Free Plan Guide
Billing Overview
Billing Items
Subscriptions
Renewals
Instructions for overdue and refunds
Comparison of EdgeOne Plans
About "clean traffic" billing instructions
DDoS Protection Capacity Description
Getting Started
Choose business scenario
Quick access to website security acceleration
Quick deploying a website with Pages
Domain Service&Origin Configuration
Domain Service
HTTPS Certificate
Origin Configuration
Site Acceleration
Overview
Access Control
Smart Acceleration
Cache Configuration
File Optimization
Network Optimization
URL Rewrite
Modifying Header
Modify the response content
Rule Engine
Image&Video Processing
Speed limit for single connection download
DDoS & Web Protection
Overview
DDoS Protection
Web Protection
Bot Management
API Discovery(Beta)
Edge Functions
Overview
Getting Started
Operation Guide
Runtime APIs
Sample Functions
Best Practices
Pages
L4 Proxy
Overview
Creating an L4 Proxy Instance
Modifying an L4 Proxy Instance
Disabling or Deleting an L4 Proxy Instance
Batch Configuring Forwarding Rules
Obtaining Real Client IPs
Data Analysis&Log Service
Log Service
Data Analysis
Alarm Service
Site and Billing Management
Billing Management
Site Management
Version Management
General Policy
General Reference
Configuration Syntax
Request and Response Actions
Country/region and Corresponding Codes
Terraform
Overview
Installing and Configuring Terraform
Practical Tutorial
EdgeOne Skill User Guide
Automatic Warm-up/Cache Purge
Resource Abuse/hotlinking Protection Practical
HTTPS Related Practices
Acceleration Optimization
Scheduling Traffic
Data Analysis and Alerting
Log Platform Integration Practices
Configuring Origin Servers for Cloud Object Storage (Such As COS)
CORS Response Configuration
API Documentation
History
Introduction
API Category
Making API Requests
Site APIs
Acceleration Domain Management APIs
Site Acceleration Configuration APIs
Edge Function APIs
Alias Domain APIs
Security Configuration APIs
Layer 4 Application Proxy APIs
Content Management APIs
Data Analysis APIs
Log Service APIs
Billing APIs
Certificate APIs
Origin Protection APIs
Load Balancing APIs
Diagnostic Tool APIs
Custom Response Page APIs
API Security APIs
DNS Record APIs
Content Identifier APIs
Legacy APIs
Ownership APIs
Image and Video Processing APIs
Multi-Channel Security Gateway APIs
Version Management APIs
Data Types
Error Codes
FAQs
Product Features FAQs
DNS Record FAQs
Domain Configuration FAQs
Site Acceleration FAQs
Data and Log FAQs
Security Protection-related Queries
Origin Configuration FAQs
Troubleshooting
Reference for Abnormal Status Codes
Troubleshooting Guide for EdgeOne 4XX/5XX Status Codes
520/524 Status Code Troubleshooting Guide
521/522 Status Code Troubleshooting Guide
Tool Guide
Agreements
Service Level Agreement
Origin Protection Enablement Conditions of Use
TEO Policy
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

CreatePurgeTask

PDF
聚焦模式
字号
最后更新时间: 2025-10-30 22:02:56

1. API Description

Domain name for API request: teo.intl.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:

  • Delete: This method deletes the node cache without verification and retrieves the latest resources from the origin when receiving a request.
  • Invalidate: This method marks the node cache as invalid and sends a request with the If-None-Match and If-Modified-Since headers to the origin. If the origin responses with 200, the latest resources are retrieved to be cached on the node. If a 304 response is returned, the latest resources are not cached on the node.

  • For more details, see [Cache Purge](https://www.tencentcloud.com/document/product/1552/70759?from_cn_redirect=1).

    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 want to quickly submit targets urls under different sites, you can set it to *, but the account calling this api must have permission for all site resources under the main account.
    Type Yes String Type of cache purging. Values:
  • purge_url: Purge by the URL
  • purge_prefix: Purge by the directory
  • purge_host: Purge by the hostname
  • purge_all: Purge all caches
  • purge_cache_tag: Purge by the cache-tag
  • For more details, see Cache Purge.
    Method No String Node cache clearing method is 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 The list of resources to purge cache, such as https://www.example.com/example.jpg, must carry protocol information. the format for multi-elements depends on the type of cache purging. refer to the following API call example.
  • the number of tasks that can be submitted at a time is limited by the billing package quota. check EO billing package.
  • .
    CacheTag No CacheTag The information attached when the node cache purge type is set to purge_cache_tag.

    3. Output Parameters

    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.

    4. Example

    Example1 Purging by the URL

    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.

    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 Purging by the hostname

    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.

  • Note: Domain names cannot include wildcards (*).
  • 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 Purging by the Cache-Tag

    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.

    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 Purging all caches under a site

    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.

    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 Purging by the directory – Deleting resources in the directory

    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.

    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 Only purging resources updated in the directory

    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.

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

    帮助和支持

    本页内容是否解决了您的问题?

    填写满意度调查问卷,共创更好文档体验。

    文档反馈