Skip to main content
Configure caching
Last update:

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 the 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 differ, 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 in both cases starts anew.

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 reloaded into 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 cache lifetime:

  1. In the Control Panel, on the top menu, click Products and select CDN.

  2. Open the CDN resource page → Settings tab.

  3. Open the Content card.

  4. 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 select Use source settings, the caching time will be equal to the time that is set on the source in the Cache-Control header . If the header is not set, the content will not be cached.
  5. Select the cache life time of the browser:

    • if you select a time period, the browser will access the source at the end of each such period;
    • If you select Use browser settings, the caching time will be equal to the time that is set in the browser settings.
  6. Click Save.

The CDN caches a single file with different cookies from the HTTP header of a Set-Cookie request as different files, and each new client request is proxied to the source. Ignoring Set-Cookie allows a file with different cookies to be cached as a single object.

  1. In the Control Panel, on the top menu, click Products and select CDN.
  2. Open the CDN resource page → Settings tab.
  3. Open the Content card.
  4. Check the Ignore Set-Cookie checkbox.
  5. 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.

  1. In the Control Panel, on the top menu, click Products and select CDN.
  2. Open the CDN resource page → Settings tab.
  3. Open the Content card.
  4. Check the Ignore query parameters checkbox.
  5. 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 moment 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 Cache: Stale header 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:

  1. In the Control Panel, on the top menu, click Products and select CDN.

  2. Open the CDN resource page → Settings tab.

  3. Open the Content card.

  4. Check the Always Online checkbox.

  5. Select the errors in which to give the last cached content:

    • Error (network problems)
    • Timeout (the response time must not exceed 5 seconds)
    • Invalid Header
    • updating (cache update)
    • Error 500
    • Error 502
    • Error 503
    • Error 504
    • Error 403
    • Error 404
    • Error 429
  6. Click Save.