> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1894.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Clear CDN resource cache by URL, pattern, or all and check purge history

[Purge](https://portal.gcore.com/cdn/purge/purge-request) is an option that clears the CDN resource cache. Use it when content on the origin is updated and waiting for natural cache expiration is not acceptable, or when CDN servers are serving incorrect content.

Three options are available for clearing the cache:

1. **Purge by URL (recommended)** to remove content that belongs to a particular URL from the cache without impacting other cached items.
2. **Purge all** to remove all data from the cache.
3. **Purge by pattern** to remove content selectively by specifying path patterns with the `*` operator that can replace any number of symbols.

The cache can be cleared in the [Gcore Customer Portal](https://portal.gcore.com) or via the [CDN Purge API](/api-reference/cdn/tools/purge-cache).

## Configure purge in the Gcore Customer Portal

1. In the Customer Portal, navigate to **CDN** → **Purge** → **Purge request**.

The Purge request page opens.

2. Select the relevant CDN resource from the dropdown menu.

3. Select the desired purge type by clicking the radio button next to it, then follow the instructions below.

4. Click the **Purge** button.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-section-overview.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=6e35e62257cf3741a277523718a26b03" alt="Purge request page with CDN resource dropdown and purge type selection" width="616" height="743" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-section-overview.png" />
</Frame>

<Tabs>
  <Tab title="Purge by URL">
    <Warning>
      Two purge requests per resource per minute are allowed. One purge request is limited to 100 URLs, so up to 200 files can be removed from the cache per minute.
    </Warning>

    In the text area, specify one or more content URLs to purge, entering one URL per line. Links must:

    * Start with a slash (/).
    * Not include a protocol, domain name, or wildcard (\*).
    * Include query strings if the CDN resource cache is configured to consider the query string.

    To purge `https://www.example.com/pictures/icon.jpg?size=small`, specify `/pictures/icon.jpg?size=small`.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-by-url.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=37efdfb957a39de0d6da75a9ecad70c0" alt="Purge by URL section with text area for entering URLs" width="582" height="518" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-by-url.png" />
    </Frame>

    Click **Show more** under the text area to see additional recommendations.

    Avoid this method in the following cases:

    * **A Vary HTTP response header is present on the origin**. Purge by URL deletes only one version of the file.
    * **Large file delivery optimization is enabled**. When several files on the origin are updated without clearing the CDN cache, Purge by URL deletes only the first slice (with bytes=0…).

    The behavior of Purge by URL also depends on the **Ignore Query string** option:

    * If the value is **Ignore All**, do not specify parameters in the Purge request.
    * If the value is **Ignore All Except**, only files with the parameters listed in the option are cached as different objects. Files with other parameters are cached as one object. In this case, specify the listed parameters in any order in the Purge request. Other parameters should not be specified.
    * If the value is **Ignore Only**, files with the parameters listed in the option are cached as one object. Files with other parameters are cached as different objects. In this case, specify other parameters (if any) besides the ones listed in any order in the Purge request.
  </Tab>

  <Tab title="Purge all">
    <Warning>
      One purge request per resource per minute is allowed. Purging all files causes a significant load on the origin server, because CDN servers pull all files from origin. For large amounts of content, use Purge by URL or pattern instead.
    </Warning>

    To purge all files from the cache, select **Purge all** and click the **Purge** button.
  </Tab>

  <Tab title="Purge by pattern">
    <Warning>
      One purge request per resource per minute is allowed. One purge request is limited to 10 patterns.
    </Warning>

    To purge files by pattern, specify the path to the file or a path pattern without a domain name in the input field. Use the `*` operator, which replaces any number of symbols at the end of the pattern. Multiple `*` operators are allowed in one request. Each path must start with `/` and be on a separate line.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-by-pattern.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=44d202c3101e69c0988d5908b6693ff6" alt="Purge by pattern radio button selected with pattern text area" width="508" height="256" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/purge-by-pattern.png" />
    </Frame>

    If a query string is not specified, files with all possible query string parameters are 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**<br /><br />Specify a file path without a domain name. As a result, all files at `cdn.site/static/image.jpg` are purged, including query string variants — `.jpg?VERSION`, for instance.<br />To purge only a file with a specific query string, include 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**<br /><br />Use the `*` operator: `/static/*`                                                                                                                                                                                                                                             | `cdn.site/static`           | `/static/*`         |
    | **3. Purge the group of files with a certain type**<br /><br />Use the `*` operator with the file name extension. All `.jpg` files are purged, including query string variants.                                                                                                                                                          | `cdn.site/static/*.jpg`     | `/static/*.jpg`     |
    | **4. Purge the group of files having a common folder in the path**<br /><br />Use the `*` operator twice.                                                                                                                                                                                                                                | `cdn.site/img/static/files` | `/img/*/files`      |
    | **5. Purge the group of files with a certain type having a common folder in the path**<br /><br />Use the `*` operator with a path pattern.                                                                                                                                                                                              | `cdn.site/img/static/*.jpg` | `/img/static/*.jpg` |
  </Tab>
</Tabs>

## Configure purge via API

The example below shows Purge by URL via API. Examples of other purge types (all and by pattern) are in the [API documentation](/api-reference/cdn/tools/purge-cache).

<Accordion title="API request details">
  | **Field**             | **Value**                                                                                                                                                                                                                                                                                                                                                                |
  | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
  | **Method**            | `POST`                                                                                                                                                                                                                                                                                                                                                                   |
  | **URL**               | `https://api.gcore.com/cdn/resources/{{resource_id}}/purge`                                                                                                                                                                                                                                                                                                              |
  | **URL parameter**     | **resource\_id**<br />ID of the CDN resource that the content to purge belongs to                                                                                                                                                                                                                                                                                        |
  | **Header**            | `Authorization: Bearer {{access_token}}`<br />`Content-Type: application/json`                                                                                                                                                                                                                                                                                           |
  | **Payload**           | **1. Purge by URL:**<br /><br />`json<br/>{<br/>  "urls": [<br/>    "/example1.jpg",<br/>    "/img/example2.png",<br/>    "/style.css?ver=2.0"<br/>  ]<br/>}<br/>`<br /><br />**2. Purge all:**<br /><br />`json<br/>{<br/>  "paths": []<br/>}<br/>`<br /><br />**3. Purge by pattern:**<br /><br />`json<br/>{<br/>  "paths": [<br/>    "/images/*"<br/>  ]<br/>}<br/>` |
  | **Request parameter** | **urls**<br />(Purge by URL, required, string) An array of one or more content URLs to purge. Each URL must start with `/`.<br /><br />**paths**<br />(Purge all) An empty array.<br />(Purge by pattern, required, string) An array of one or more content patterns. Each pattern must start with `/`.                                                                  |
  | **Response**          | **201 Created**<br />Returns an array of the purged URLs<br /><br />**400 Bad Request**<br />The user has exceeded the URL quota<br /><br />**401 Unauthorized**<br />The user does not have the correct authentication credentials<br /><br />**429 Too many requests**<br />The user has exceeded the request quota                                                    |
</Accordion>

An [API token](/api-reference/iam/account/login) is required for authenticated requests. The example below uses 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 the actual value.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339834314641.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=bb981e3489102b63fcdb4d1dd6180070" alt="Postman request tab with POST method and resource URL" width="1248" height="271" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339834314641.png" />
</Frame>

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

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339852303249.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=125aaa2cb1550e04e938f6ca0d3759f3" alt="Postman Authorization tab with Bearer Token type selected" width="1243" height="495" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339852303249.png" />
</Frame>

3. Navigate 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 actual values.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339837932177.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=244f9d34c09bcc8964769dc38bb3c3c0" alt="Postman Body tab with raw JSON payload" width="1242" height="476" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339837932177.png" />
</Frame>

4. Click **Send**.

If the purge is successful, the API returns HTTP 201 and a response body containing a list of purged URLs.

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339892700945.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=50908e8ab186ed8ce76828f08b04d567" alt="Postman showing HTTP 201 response with list of purged URLs" width="1242" height="317" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339892700945.png" />
</Frame>

If an error occurs, the API returns a status code and a response body describing the cause. Example:

<Frame>
  <img src="https://mintcdn.com/gcore-doc-1894/9U1xXa0egFyWElxm/images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339878706961.png?fit=max&auto=format&n=9U1xXa0egFyWElxm&q=85&s=ee1ab907e3d0817caf53e4407f8b7070" alt="Postman showing error response with status code and description" width="1247" height="341" data-path="images/docs/cdn/clear-cdn-resource-cache-by-url-pattern-or-all/14339878706961.png" />
</Frame>

## View purge history

**Purge history** is the section where the status of all purge requests can be checked.

<Note>
  Purge history stores requests for the past month only.
</Note>

To view the history, navigate to the [Purge history](https://portal.gcore.com/cdn/purge/purge-history) page. The page displays all existing requests.

Use filters to display specific requests:

* **Search by CNAME.** Specify the CNAME of the CDN resource.
* **Type.** Select the purge type (Purge by URL, Purge all, or Purge by pattern).
* **Status.** Select the status (In progress, Successful, Failed, or Status report disabled).
* **Date.** Set the time period (up to one month).
