Configure caching
Customize cache lifetime
When a file is cached, the cache lifetime — the period in which a CDN server or browser gives users a cached version of a file without accessing the source — begins to run.
When the cache lifetime expires, the CDN server or user's browser compares the versions of the file in the cache and at the source — if the versions are different, the file in the cache is replaced with a fresh version from the source. If the versions are not different, the file in the cache remains the same. The cache lifetime for this file starts again in both cases.
If a file in the cache has not been accessed for more than 36 hours, it is automatically deleted from the cache, even if its lifetime has not yet expired. The file will be re-uploaded to the cache only if it is requested by the user.
You can customize the cache lifetime on CDN servers and in the user's browser.
To change the lifetime of the cache:
-
In control panel go to CDN → CDN resources.
-
Open the CDN resource page → tab Settings.
-
Open the card Content.
-
Select the maximum cache lifetime on CDN servers:
- if you select a time period, the CDN server will access the source at the end of each such period;
- if you choose Use source settings, the caching time will be equal to the time that is set on the source in the header
Cache-Control
. If the header is not set, the content will not be cached.
-
Select the cache lifetime of your browser:
- if you select a time period, the browser will access the source at the end of each such period;
- if you choose Use source settings, the caching time will be equal to the time that is set on the source in the header
Cache-Control
. If the header is not set, the content will not be cached.
-
Click Save.
Ignore Set-Cookie
CDN caches a single file with different cookies from the HTTP request header Set-Cookie
as different files, and each new client request is proxied to the source. Ignoring Set-Cookie
allows you to cache a file with different cookies as a single object.
- In control panel go to CDN → CDN resources.
- Open the CDN resource page → tab Settings.
- Open the card Content.
- Check the box Ignore Set-Cookie.
- Click Save.
Ignore request parameters
If requests for the same file contain different parameters (the part after the question mark in the file URL), each request with a new parameter is proxied to the source. Ignoring request parameters allows caching files with different request parameters as a single object.
- In control panel go to CDN → CDN resources.
- Open the CDN resource page → tab Settings.
- Open the card Content.
- Check the box Ignore request parameters.
- Click Save.
Give cache on source errors
This option allows you to retrieve the last cached content if the source responds with an error. At the time of the error, not all site data may be in the cache — for example, not all images, videos or stylesheets. In this case, the site pages may not be displayed in full.
If the source responded with an error when requested, CDN servers will check its availability with each new request:
- if the error persists, CDN servers will give the last cached content with the header
Cache: Stale
until the cache lifetime expires; - if the source functionality is restored, the CDN will cache a fresh version of the file.
To enable cache giveaway on source errors:
-
In control panel go to CDN → CDN resources.
-
Open the CDN resource page → tab Settings.
-
Open the card Content.
-
Check the box Always online.
-
Select the errors in which to give the last cached content:
Error
(network issues)Timeout
(response time should not exceed 5 seconds)Invalid Header
updating
(cache update)Error 500
Error 502
Error 503
Error 504
Error 403
Error 404
Error 429
-
Click Save.