Forced file upload to the CDN server cache
In the CDN resource settings, you can enable content caching to temporarily store the copies of files loaded from origins on CDN servers.
At the same time, you can forcibly upload files from origins to the CDN server cache. We recommend prefetching large files, i.e., those of 200 MB or more.
To forcibly upload content from a CDN resource to the CDN server cache:
Warning
You can only prefetch the cache for content that is not yet available on CDN servers. To update cached files, you need to purge the cache first.
- In the management console
, select the folder where your resource is located. - Go to Cloud CDN.
- Click the resource name.
- Navigate to the Content tab.
- In the top-right corner, click
and select Preload content. - Enter the file names in the File path field.
- Click Preload content.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
View the description of the CLI command to update a resource:
yc cdn resource update --help -
Get a list of all resources in the default folder:
yc cdn resource list --format yamlResult:
id: s0me1dkfjq******** folder_id: s0mef01der7p******** cname: testexample.com created_at: "2022-01-19T09:23:57.921365Z" updated_at: "2022-01-19T10:55:30.305141Z" active: true options: edge_cache_settings: enabled: true default value: "345600" cache_http_headers: enabled: true value: - content-type - content-length - connection - server - date - test stale: enabled: true value: - error - updating allowed_http_methods: value: - GET - POST - HEAD - OPTIONS origin_group_id: "89783" origin_group_name: My origins group origin_protocol: HTTP ssl_certificate: type: DONT_USE status: READY -
Specify the paths to the files you want to upload to the CDN server cache as a comma-separated list with no spaces:
yc cdn cache prefetch --resource-id <resource_ID> \ --path <file_paths>For more information about the
yc cdn cache prefetchcommand, see the CLI reference.
Use the prefetch REST API method for the Cache resource or the CacheService/Prefetch gRPC API call.