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 a file without accessing the source — begins to run.

When the cache lifetime expires, the CDN server or the 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 starts over in both cases.

If there are no requests for a file in the cache for longer 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 the user requests it.

You can customize the cache lifetime on CDN servers and in the user's browser.

To change the lifetime of the cache:

  1. In Control Panel, go to CDNCDN Resources.

  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 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 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.
  6. Click Save.

The CDN caches a single file with different cookies from the Set-Cookie HTTP request header 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 Control Panel, go to CDNCDN Resources.
  2. Open the CDN resource page → Settings tab.
  3. Open the Content card.
  4. Check the Agnore Set-Cookie checkbox.
  5. Click Save.

Ignore request parameters

If requests to 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 files with different request parameters to be cached as a single object.

  1. In Control Panel, go to CDNCDN Resources.
  2. Open the CDN resource page → Settings tab.
  3. Open the Content card.
  4. Check the Agnore request parameters checkbox.
  5. Click Save.

Give cache on source errors

The option allows you to give 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 such a case, the pages of the site may not be displayed completely.

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 Control Panel, go to CDNCDN Resources.

  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 (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.
  6. Click Save.