Purge is an option that allows clearing the CDN resource cache. Using Purge is helpful if you update the content on your origin and don’t want to wait until the content is updated on CDN servers naturally because it takes time. After Purge is applied, the outdated CDN server’s cache will disappear. Additionally, the option assists if your end-users receive incorrect content of your website data from CDN servers.
We provide three options for cache clearing:
There are two ways to clear the cache: via API (use the API documentation to get more information about the request) and in the Customer Portal.
1. Go to the Purge request section.
A new page will open. Perform the remaining steps there.
2. Select the relevant CDN resource from the dropdown menu.
3. Select the desired purge type and follow the instructions below (by URL, all, or by pattern).
4. Click the Purge button.
You can make two purge requests per resource per minute. One purge request is limited to 100 URLs. Therefore, you can remove up to 200 files from the cache per minute.
In the text area, specify one or more content URLs to purge, entering one URL per line. Links must:
For example, to purge the file https://www.example.com/pictures/icon.jpg?size=small
, specify /pictures/icon.jpg?size=small
.
We recommend avoiding this method and instead using other types of Purge in the following cases:
The configuration of Purge by URL also depends on the settings in the Ignore Query string option:
You can make one purge request per resource per minute.
Purging all files from the cache will cause a significant load on your server as CDN servers will pull all files from the origin. Therefore, if you have a large amount of content, we recommend using Purge by URL or pattern.
To purge all files from the cache, select the "Purge All" option and click the Purge button.
You can make one purge request per resource per minute. One purge request is limited to 10 patterns.
To purge files by pattern, specify the path to the file you want to purge or a path pattern without a domain name in the input line. Use the * operator, which replaces any number of symbols in your path. You can use several * operators in one request. A path must start with / or * and each path must be on a separate line.
If you don’t specify a query string, files with all the possible query string parameters will be purged from the cache according to the path pattern.
Several types of patterns are available:
Type and explanation | Purge target | Purge pattern |
1. Purge the selected file Specify a file path without a domain name. As a result, all files at cdn.site/static/image.jpg will be purged, including files with query string .jpg?VERSION If you only want to purge a selected file with a query string, specify it in the file path: /static/image.jpg?VERSION |
cdn.site/static/image.jpg | /static/image.jpg |
2. Purge the group of files from one folder Input pattern without a domain name and * operator: /statiс/* |
cdn.site/static | /statiс/* |
3. Purge the group of files with a certain type Input the * operator and the file name extension .jpg As a result, all the jpg files will be purged, including files with the query string .jpg?VERSION |
cdn.site/*.jpg | *.jpg |
4. Purge the group of files having a common folder in the path Input path pattern without a domain name and use the * operator twice |
cdn.site/*/static/* | */static/* |
5. Purge the group of files with a certain type having a common folder in the path Input path pattern with the * operator |
cdn.site/*/static/*.jpg | */static/*.jpg |
We will explain in detail how to do "Purge by URL" via API calls. Examples of other Purge types (all and by pattern) can be found in the API documentation.
Method | POST |
URL | https://api.gcore.com/cdn/resources/{{resource_id}}/purge |
URL parameter | resource_id ID of the CDN resource that the content to purge belongs to |
Header | Bearer {{access_token}} application/json |
Payload |
1. Purge by URL: { 2. Purge all: { "paths": [ ] 3. Purge by pattern: { |
Request parameter |
paths 1. Purge by URL: (required, string) An array of one or more content URLs to purge 2. Purge all: An empty array. 3. Purge by pattern: (required, string) An array of one or more content patterns started with * or / symbols. |
Response |
201 Created 400 Bad Request 401 Unauthorized 429 Too many requests |
To access the API and make authenticated requests, generate an access token. You can use a REST tool like cURL or Postman to send the requests. For this guide, we used Postman.
To send a purge by URL request:
1. In Postman, open a new request tab, then do the following:
a. Set the request method to POST.
b. Enter the resource URL in the request URL field. Replace {{resource_id}} with your actual value.
2. Go to the Authorization tab and do the following:
a. Select Bearer Token from the Type dropdown.
b. Copy the generated access token and paste it into the Token field.
3. Go to the Body tab and do the following:
a. Select raw as the data type.
b. Select JSON from the format dropdown.
c. Enter the payload in the text area. Replace the sample values indicated by {{ }} with your actual values.
4. Click Send.
If the purge is successful, you will receive an HTTP 201 and a response message that contains a list of purged URLs.
If an error occurs with the request, the API will return a status code and a body that contains a description of what caused the error. Here is an example:
This feature is currently in beta.
“Purge history” is the section where you can check the status of your purge requests.
Note: We've been keeping a history of purge requests for only one month.
To view the history, navigate to the Purge history page. The page will display all existing requests.
You can use filters to display individual reports:
Was this article helpful?
Learn more about our next-gen CDN