Skip to main content

Configure content caching

By default, content caching settings are disabled. You can enable and configure them:

Configure caching time

The caching time is the duration for which CDN servers store a copy of the response from the origin before re-requesting content. Caching time can be configured for each HTTP response.

  1. In the control panel, on the top menu, click Products and select CDN.

  2. In the CDN Resources section, open the CDN resource page → Caching tab.

  3. Check the Enable caching settings checkbox.

  4. In the Content caching time block, configure the caching time for each response type:

    • for 2xx — retention time for successful responses;
    • 3xx — retention time for redirects;
    • 4xx — retention time for client errors;
    • 5xx — retention time for server errors;
    • in browser — the time the browser can cache a response after receiving it from the CDN.
  5. To override the content source settings with your own, check the Ignore cache control headers checkbox. The CDN will ignore Cache-Control and Expires headers that contain caching information from the content source.

  6. Click Apply. While settings are being applied, the CDN resource enters the PROCESSING status. You cannot apply other settings during this time. Settings take effect when the CDN resource transitions to ACTIVE.

Serve content from cache on source errors

If the content source returns an error, the user can receive the last cached version of the content (Use Stale). While the source is unavailable, site pages may not display correctly: for example, some images, videos, or stylesheets may not work. CDN servers will check the availability of the source with each new request:

  • if the error persists, CDN servers will serve the last cached content with the Cache: Stale header;
  • if the source functionality is restored, the CDN server will cache the fresh version of the file.

To serve content from cache on source errors:

  1. In the control panel, on the top menu, click Products and select CDN.

  2. In the CDN Resources section, open the CDN resource page → Caching.

  3. Check the Enable caching settings checkbox.

  4. In the Last cached content version (Use Stale) block, check the Serve the last cached version if the source is unavailable.

  5. In the Serve stale content on list, select the errors that should trigger serving the last cached content:

    • error — connection error to the server;
    • timeout — connection timeout with the server;
    • invalid_header — the server returned an empty or invalid response;
    • updating — serve stale cached response while files in cache are being updated;
    • http_500 — internal server error;
    • http_502 — bad gateway error;
    • http_503 — server cannot process the request;
    • http_504 — gateway timeout;
    • http_403 — forbidden error;
    • http_404 — CDN resource not found;
    • http_429 — too many requests.
  6. Click Apply. While settings are being applied, the CDN resource enters the PROCESSING status. You cannot apply other settings during this time. Settings take effect when the CDN resource transitions to ACTIVE.

Cache content by query string

By default, the CDN ignores query strings (query string).

You can enable caching content by query string.

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 redirected to the source.

  1. In the control panel, on the top menu, click Products and select CDN.

  2. In the CDN Resources section, open the CDN resource page → Caching.

  3. Check the Enable caching settings checkbox.

  4. In the Cache by query string block, check the Cache by query string checkbox. By default, all query parameters will be considered.

  5. If you want to consider specific request parameters, uncheck the Consider all parameters checkbox.

  6. Enter the query parameter. You can enter an allowed or forbidden parameter:

    • to specify an allowed parameter, enable White List, add the parameter, and click . Only parameters included in this list will be considered when processing requests.

    • to specify a forbidden parameter, enable Black List, add the parameter, and click . All parameters not included in this list will be considered when processing requests.

  7. To add another query parameter, repeat step 6.

  8. Click Apply. While settings are being applied, the CDN resource enters the PROCESSING status. You cannot apply other settings during this time. Settings take effect when the CDN resource transitions to ACTIVE.

Cache content by cookies

By default, the CDN ignores cookies.

You can enable content caching based on cookie parameters.

The CDN caches one file with different cookies from the HTTP request header as distinct files, and every new user request is forwarded to the origin.

  1. In the control panel, click Products on the top menu and select CDN.

  2. In the CDN Resources section, open the CDN resource page → Caching.

  3. Select the Enable caching settings checkbox.

  4. In the Cache by cookies section, select the Cache by cookies checkbox. By default, all cookies will be considered.

  5. If you want to consider specific cookies in the request, clear the Consider all parameters checkbox.

  6. Enter the cookie parameter. You can enter an allowed or forbidden parameter:

    • to enter an allowed cookie parameter, enable White List, add the allowed parameter, and click . Only cookie parameters included in this list will be considered when processing requests;

    • to enter a forbidden cookie parameter, enable Black List, add the forbidden parameter, and click . All parameters that are not included in this list will be considered when processing requests.

  7. To add another cookie parameter, repeat step 6.

  8. Click Apply. While settings are being applied, the CDN resource enters the PROCESSING status. You cannot apply other settings during this time. Settings take effect when the CDN resource transitions to ACTIVE.