Files are updated according to the cache settings. By default, a cache’s lifetime is 24 hours. This means that every 24 hours, the CDN communicates with the origin and checks to see if any cached files have been updated or changed. If they have, then the CDN downloads the latest version from the primary server.
Files that are not requested for an extended period of time are automatically deleted from the caching server. If a new request comes in, then the file is once again downloaded from the primary server.
The cache lifetime can be changed under the Cache tab in the Cache Settings block. Enter the maximum cache lifetime on the CDN servers and the browser cache lifetime.
As additional settings, you can enter:
Ignore Set-Cookie — this option allows you to cache a file with different Cookies as a single object, otherwise the CDN caches the same file with different cookies from the HTTP header of the Set-Cookie request as different files. As a result, each new client request is proxied to the source, and not delivered from the cache;
Ignore request parameters — this option allows you to cache files with different query parameters as objects with the same key, regardless of the parameter value. The query parameter is a unique query string (the parameter after the question mark) in the URL;
Always online — this option allows to return the latest cached content if the content source isn’t available with the errors:
- error (network problems)
- updating (cache update)
The source availability will be checked with each user request. If the source has recovered, the CDN will cache the latest version of the file. If the source has not recovered, the CDN servers will deliver the content until the cache expires.
- Speed up caching of large files — this option is used to speed up caching of large files. Files larger than 10 MB will be stored in cache in 10 MB parts, for example, a 56 MB file will be divided into 6 parts: 5 of which are 10 MB each and the last is the remaining volume.
Purging the Cache
Clearing the cache may be required, for example, in case of updating the content on the source or if the data in the CDN is not displayed correctly.
Selective Cache Flushing
To selectively clear the cache:
- Enter the relative path to the file or path template.
Note: always indicate * or / at the beginning of the path. * replaces any number of characters.
Indicate each path as a separate line, for example:
- Click Purge cache.
How to clear the cache of a single file cdn.site/static/image.jpg?
Enter the path to the file without a domain name: /static/image.jpg. Click Purge cache. All files will be deleted at cdn.site/static/image.jpg, including files that have query parameters .jpg?VERSION. If query parameters are used, enter the path with query parameters: /static/image.jpg?VERSION.
How to clear the cache for a group of files located in cdn.site/static?
Enter path mask without domain name and operator *: /static/. Click Purge cache.
How to clear the cache of a group of files with the extension .jpg?
Enter the * operator and file extension: *.jpg. Click Purge cache.
All files with the jpg extension, including files having the request parameters .jpg?VERSION, will be deleted.
How to clear the cache of a group of files containing the path / static /?
Enter the path mask without the domain name and the operator * twice: /static/. Click Purge cache.
How to clear the cache of a group of files containing in the path / static / with the extension .jpg?
Enter the path mask. Use the operator * : /static/.jpg. Click Purge cache.
Restrictions on cleaning:
- no more than 1 request per minute;
- no more than 50 path patterns in the request;
- cleaning time depends on the number of files.
Full Purge the Cache
To fully purge the cache:
- Click Purge all cache.
- Confirm the operation. The amount of time it takes to purge the cache depends on the number of objects it has stored.
To prefetch the cache:
- Enter the relative path to the file. Always indicate / at the beginning of the path. Indicate each path as a separate line, for example: ‘/path/file1.jpg’.
- Click Prefetch Cache.
Content compression will reduce content delivery time. Depending on the request parameters, the client will receive a compressed or uncompressed file:
- on CDN-servers — files will be compressed on CDN servers using gzip;
- at source — files will be compressed on the source. For the compression and storage of two versions of the file to work correctly in the cache of the CDN server, configure Accept‑Encoding HTTP headers: gzip and/or deflate and Vary: Accept-Encoding on the source.
File extensions that support compression:
Image file formats (jpeg, jpg, png) supported by web files, as well as videos, PDFs and other binary formats, are already compressed. Using gzip on them does not provide additional benefits.