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

# Prefetch content

> Pre-populate files to a CDN cache before users requests. Prefetch is recommended only for files that **more than 200 MB** and **less than 5 GB**.

You can make one prefetch request for a CDN resource per minute. One request for prefetch may content only up to 100 paths to files.

The time of procedure depends on the number and size of the files.

If you need to update files stored in the CDN, first purge these files and then prefetch.



## OpenAPI

````yaml /api-reference/services_documented/cdn_api.yaml post /cdn/resources/{resource_id}/prefetch
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-07T20:33:46.548242+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}/prefetch:
    post:
      tags:
        - Tools
      summary: Prefetch content
      description: >-
        Pre-populate files to a CDN cache before users requests. Prefetch is
        recommended only for files that **more than 200 MB** and **less than 5
        GB**.


        You can make one prefetch request for a CDN resource per minute. One
        request for prefetch may content only up to 100 paths to files.


        The time of procedure depends on the number and size of the files.


        If you need to update files stored in the CDN, first purge these files
        and then prefetch.
      operationId: prefetch-content
      parameters:
        - $ref: '#/components/parameters/resource_id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResourcePrefetch'
      responses:
        '201':
          description: Successful.
        '400':
          description: Prefetch request validation is failed.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/IncorrectPathsItemsPurgeOrPrefetchError
                  - $ref: '#/components/schemas/JSONParseError'
        '429':
          description: >-
            You have exceeded number of allowed prefetch 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.prefetch(
                resource_id=0,
                paths=["/test.jpg", "test1.jpg"],
            )
        - 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.Prefetch(\n\t\tcontext.TODO(),\n\t\t0,\n\t\tcdn.CDNResourcePrefetchParams{\n\t\t\tPaths: []string{\"/test.jpg\", \"test1.jpg\"},\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:
    ResourcePrefetch:
      type: object
      properties:
        paths:
          type: array
          description: |-
            Paths to files that should be pre-populated to the CDN.

            Paths to the files should be specified without a domain name.
          items:
            type: string
          example:
            - /test.jpg
            - test1.jpg
      required:
        - paths
    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

````