Create a purge request to force a refresh of the content stored in the CDN Pro cache servers. You may wish to do this if you just updated content on your origin server and want visitors to see the changes right away rather than wait for the updates to propagate according to the schedule defined in your property configuration.
| Name | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
nameString | A description of the purge request. | ||||||||||||||||||
fileUrlsList | URLs of files to purge. File URLs should not contain the asterisk character, '*'. If a directory or filename in a URL includes a percent character, '%', be sure to encode it. A URL can be up to 2048 characters. | ||||||||||||||||||
fileHeadersList | If a file's cache key depends on request headers, you can specify the header values that are applicable to purge one version of the cached file. The same set of header values will apply to all entries in fileUrls. | ||||||||||||||||||
nameString | HTTP header name. | ||||||||||||||||||
valueString | Value of an HTTP header. | ||||||||||||||||||
dirUrlsList | <= 20 items
URLs to purge. URLs must begin with http:// or https:// and can be up to 2048 characters. Use the '*' character to purge multiple files or directories. If a URL has multiple sets of asterisk characters, only the last '*' or '**' will be treated as a wildcard. Other instances of '*' earlier in the URL will be treated as the literal character '*'.
| ||||||||||||||||||
regexPatternsList | <= 2 items
Regular expression patterns used to match the cache key. Each must begin with the following format:
{scheme}://{hostname}/. {scheme} can be http, https, or any, which matches any scheme.
Example:
https://test.domain.com/my.*\.(jpg|png)\?q=
For performance considerations, the following restrictions apply: The regular expression pattern following the hostname can be up to 126 characters. It can consist of up to two unlimited quantifiers ('*', '+', or ',}'). The upper limit on a quantifier cannot be more than 59, for example, {1,59} | ||||||||||||||||||
actionString | Enum: delete invalidate
Default: invalidate
This controls whether cached files and directories should be removed altogether from the CDN Pro servers (delete) or flagged as invalid (invalidate). | ||||||||||||||||||
*targetString | Enum: staging production
Specify if the purge request applies to the staging or production environment. | ||||||||||||||||||
webhookString | ID of a webhook to call when the purge task completes. |
| Name | Description |
|---|---|
LocationString | Returns a URL pointing to the new purge task created, if the request is accepted. The URL contains the ID of the new purge task. URL format: {scheme}://{domain}/cdn/purges/{purgeId} Example URL: https://api.example.com/cdn/purges/5dca2205f9e9cc0001df7b33 |
| Error code(code) | Description(message) | HTTP status | Semantic |
|---|---|---|---|
| InvalidPurgeUrl | The host 'test.domain.info' has not been deployed in the 'production' environment. | 400 | The host 'test.domain.info' has not been deployed in the 'production' environment. |
| InvalidPurgeUrl | The purge URL 'http://domain.info/newfile[1]{tes`|t^}p.png' is invalid. Special letters need to be encoded. | 400 | The purge URL 'http://domain.info/newfile[1]{tes`|t^}p<u>.png' is invalid. Special letters need to be encoded. |
| InvalidPurgeUrl | The purge URL 'http://domain.info/i/image/gallery/123%abc.jpg' is invalid. Special letters need to be encoded. | 400 | The purge URL 'http://domain.info/i/image/gallery/123%abc.jpg' is invalid. Special letters need to be encoded. |
#!/bin/bash
username="example_username"
apiKey="example_apiKey"
date=`env LANG="en_US.UTF-8" date -u "+%a, %d %b %Y %H:%M:%S GMT"`
password=`echo -en "$date" | openssl dgst -sha1 -hmac $apiKey -binary | openssl enc -base64`
curl -i --url "https://api.cdnetworks.com/cdn/purges" \
-X "POST" \
-u "$username:$password" \
-H "Date: $date" \
-H "Accept: application/json" \
-d '{
"fileUrls": [
"http://domain.info/i/image/gallery/123.jpg",
"http://test.domain2.com/2.txt?q1=1&q2=3"
],
"fileHeaders": [
{
"name": "customheader1",
"value": "test1"
},
{
"name": "customheader2",
"value": "test2"
}
],
"action": "invalidate",
"target": "production"
}'HTTP/1.1 201 Created Date: Mon, 11 Aug 2025 06:15:25 GMT Content-Type: application/json;charset=utf-8 Content-Length: 0 Location: https://open.chinanetcenter.com/cdn/purges/5dca2205f9e9cc0001df7b33