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

# Purge cache

> Delete cache from CDN servers. This is necessary to update CDN content.

We have different limits for different purge types:
- **Purge all cache** - One purge request for a CDN resource per minute.
- **Purge by URL** - Two purge requests for a CDN resource per minute. One purge request is limited to 100 URLs.
- **Purge by pattern** - One purge request for a CDN resource per minute. One purge request is limited to 10 patterns.



## OpenAPI

````yaml /api-reference/services_documented/cdn_api.yaml post /cdn/resources/{resource_id}/purge
openapi: 3.1.0
info:
  title: Gcore OpenAPI – CDN API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-14T07:00:22.640261+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: CDN service
    description: Information about the current state of the CDN service in your account.
    x-displayName: CDN service
  - name: CDN resources
    x-displayName: CDN resources
  - name: Origins
    x-displayName: Origins
  - name: Rules
    description: >-
      Rules allow to set up custom settings for certain file types or paths.

      By default, the rule inherits all options values from the related CDN
      resource.


      Each option in rule settings can be in one of the following states:

      - **Inherit** - Option is not added to the rule. Option inherits its value
      from the CDN resource settings. In this case, the option value is
      **null**.

      - **ON** - Option is added to the rule and enabled. Option values
      configured in the rule will override values from the CDN resource
      settings.

      - **OFF** - Option is added to the rule and disabled. Option will be
      turned off.
    x-displayName: Rules
  - name: Rule templates
    x-displayName: Rule templates
  - name: SSL certificates
    x-displayName: SSL certificates
  - name: Let's Encrypt certificates
    x-displayName: Let's Encrypt certificates
  - name: CA certificates
    x-displayName: CA certificates
  - name: CDN activity logs
    description: |-
      Get the history of users requests to CDN.
      It contains requests made both via the API and via the control panel.

      The following methods are not tracked in the activity logs:
      - HEAD
      - OPTIONS
    x-displayName: CDN activity logs
  - name: Log viewer
    description: >-
      Log viewer provides you with general information about CDN operation. This
      information does not contain all possible

      sets of fields and restricted by time. To receive full data, use Logs
      Uploader.
    x-displayName: Log viewer
  - name: Logs uploader
    description: >-
      Logs uploader allows you to upload logs with desired format to desired
      storages.


      Consists of three main parts:

      - **Policies** - rules that define which logs are uploaded and how they
      are uploaded.

      - **Targets** - destinations where logs are uploaded.

      - **Configs** - combinations of logs uploader policies, targets and
      resources to which they are applied.
    x-displayName: Logs uploader
  - name: Tools
    x-displayName: Tools
  - name: CDN Statistics
    description: >-
      Consumption statistics is updated in near real-time as a standard
      practice.

      However, the frequency of updates can vary, but they are typically
      available within a 24-hour period.

      Exceptions, such as maintenance periods, may delay data beyond 24 hours
      until servers resume and fill in the missing statistics.
    x-displayName: Statistics
  - name: Advanced analytics
    description: >-
      Advanced analytics allows to get statistics about unique visitors,
      traffic, and requests for countries, directories, browsers, devices, and
      operation systems for up to 90 days starting from today.


      Advanced analytics API is based on the [GraphQL
      framework](https://graphql.org/).


      Advanced analytics API has one single endpoint:

       https://api.gcore.com/cdn/advanced/v2/query

      You can pass the query parameters as a JSON object in the payload of a
      POST request to this endpoint.

      You can use curl to make requests to the Advanced analytics API.
      Alternatively, you can use a GraphQL client

      to construct queries and pass requests to the Advanced analytics API.


      You can write queries in GraphQL much like in SQL: specify the data set
      (CDN resource), the metrics

      to retrieve (such as unique visitors and traffic), and filter or group by
      dimensions (for example, a country).
    x-displayName: Advanced analytics
  - name: Origin shielding
    x-displayName: Origin shielding
  - name: IP addresses list
    x-displayName: IP addresses list
  - name: Purge history
    x-displayName: Purge history
paths:
  /cdn/resources/{resource_id}/purge:
    post:
      tags:
        - Tools
      summary: Purge cache
      description: >-
        Delete cache from CDN servers. This is necessary to update CDN content.


        We have different limits for different purge types:

        - **Purge all cache** - One purge request for a CDN resource per minute.

        - **Purge by URL** - Two purge requests for a CDN resource per minute.
        One purge request is limited to 100 URLs.

        - **Purge by pattern** - One purge request for a CDN resource per
        minute. One purge request is limited to 10 patterns.
      operationId: purge-cache
      parameters:
        - $ref: '#/components/parameters/resource_id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResourcePurge'
      responses:
        '201':
          description: Successful.
        '400':
          description: Failed to purge the CDN resource cache.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/PathsNotProvidedPurgeError'
                  - $ref: '#/components/schemas/IncorrectPathsTypePurgeError'
                  - $ref: '#/components/schemas/IncorrectPathsFormatPurgeError'
                  - $ref: >-
                      #/components/schemas/IncorrectPathsItemsPurgeOrPrefetchError
                  - $ref: '#/components/schemas/JSONParseError'
        '429':
          description: >-
            You have exceeded number of allowed purge requests for your CDN
            resource.
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from gcore import Gcore

            client = Gcore(
                api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
            )
            client.cdn.cdn_resources.purge(
                resource_id=0,
            )
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/G-Core/gcore-go\"\n\t\"github.com/G-Core/gcore-go/cdn\"\n\t\"github.com/G-Core/gcore-go/option\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\terr := client.CDN.CDNResources.Purge(\n\t\tcontext.TODO(),\n\t\t0,\n\t\tcdn.CDNResourcePurgeParams{\n\t\t\tOfPurgeByURL: &cdn.CDNResourcePurgeParamsBodyPurgeByURL{},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n"
components:
  parameters:
    resource_id:
      in: path
      name: resource_id
      description: CDN resource ID.
      required: true
      schema:
        type: integer
  schemas:
    ResourcePurge:
      oneOf:
        - type: object
          title: Purge by URL
          properties:
            urls:
              type: array
              items:
                type: string
              description: >-
                **Purge by URL** clears the cache of a specific files. This
                purge type is recommended.


                Specify file URLs including query strings. URLs should start
                with / without a domain name.


                Purge by URL depends on the following CDN options:


                1. "vary response header" is used. If your origin serves
                variants of the same content depending on the Vary HTTP response
                header, purge by URL will delete only one version of the file.

                2. "slice" is used. If you update several files in the origin
                without clearing the CDN cache, purge by URL will delete only
                the first slice (with bytes=0… .)

                3. "ignoreQueryString" is used. Don’t specify parameters in the
                purge request.

                4. "query_params_blacklist" is used. Only files with the listed
                in the option parameters will be cached as different objects.
                Files with other parameters will be cached as one object. In
                this case, specify the listed parameters in the Purge request.
                Don't specify other parameters.

                5. "query_params_whitelist" is used. Files with listed in the
                option parameters will be cached as one object. Files with other
                parameters will be cached as different objects. In this case,
                specify other parameters (if any) besides the ones listed in the
                purge request.
          example:
            urls:
              - /some-url.jpg
              - /img/example.jpg
        - type: object
          title: Purge by pattern
          properties:
            paths:
              type: array
              items:
                type: string
              description: >-
                **Purge by pattern** clears the cache that matches the pattern.


                Use * operator, which replaces any number of symbols in your
                path. It's important to note that wildcard usage (*) is
                permitted only at the end of a pattern.


                Query string added to any patterns will be ignored, and purge
                request will be processed as if there weren't any parameters.


                Purge by pattern is recursive. Both /path and /path* will result
                in recursive purging, meaning all content under the specified
                path will be affected. As such, using the pattern /path* is
                functionally equivalent to simply using /path.
          example:
            paths:
              - /images/*
              - /videos/*
        - type: object
          title: Purge all cache
          properties:
            paths:
              type: array
              items:
                type: string
              description: >-
                **Purge all cache** clears the entire cache for the CDN
                resource.


                Specify an empty array to purge all content for the resource.


                When you purge all assets, CDN servers request content from your
                origin server and cause a high load. Therefore, we recommend to
                use purge by URL for large content quantities.
          example:
            paths: []
    PathsNotProvidedPurgeError:
      title: Paths not provided
      type: object
      properties:
        errors:
          type: object
          properties:
            paths:
              type: array
              description: >-
                The field "paths" is not set. Define "paths" field in request
                body.
              items:
                type: string
              example:
                - This field is required.
    IncorrectPathsTypePurgeError:
      title: Incorrect paths type provided
      type: object
      properties:
        errors:
          type: object
          properties:
            paths:
              type: array
              description: The field "paths" is incorrect. Must be an array of strings.
              items:
                type: string
              example:
                - Expected a list of items but got type "str".
    IncorrectPathsFormatPurgeError:
      title: Incorrect paths format provided
      type: object
      properties:
        errors:
          type: object
          properties:
            paths:
              type: array
              description: The field "paths" has invalid values.
              items:
                type: string
              example:
                - A path should start with /.
    IncorrectPathsItemsPurgeOrPrefetchError:
      title: Incorrect paths items provided
      type: object
      properties:
        errors:
          type: object
          properties:
            paths:
              type: object
              properties:
                index:
                  type: array
                  description: Some items in "paths" is invalid.
                  items:
                    type: string
                  example:
                    - This field may not be blank.
    JSONParseError:
      title: Invalid request JSON schema
      type: object
      properties:
        message:
          type: string
          description: >-
            This message describes error if json schema from your request is
            invalid.
          example: >
            JSON parse error - Expecting ',' delimiter: line 3 column 33 (char
            77)
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````