BillingCDN resources overviewOrigin groupPurgePrefetchReports
Chosen image
Home/CDN/CDN resource options/Cache/Configure browser caching

Specify cache lifetime for user browsers

What is the Browser Caching option?

The Browser Caching option allows you to set the period of content caching in the end users' browser. The option has two modes: Origin controlled and CDN controlled. The difference between these two modes is that in the first case, the caching time is configured in your source site's configuration, and in the second case, in the Gcore control panel.

Origin controlled

If you choose the Origin controlled mode, the content will be cached based on the origin settings specified in the Cache-Control header. For example, if your Cache-Control header is set as Cache-Control: max-age=172800 on your origin in seconds, the content will be cached for 2 days on the CDN servers.

If the Cache-Control header is not specified, then most browsers will consider the Last-Modified header to decide how to handle files in the cache.

Note: The content will not be cached if there are no cache settings on your origin.

CDN controlled

If you choose the CDN controlled mode, the content will be cached based on the cache duration set for this option in the control panel. You can select a value from the list or set a custom value in seconds.

Note: Here are the HTTP response codes that can be cached in browsers: 200, 201, 204, 206, 301, 302, 303, 304, 307, 308. Other response codes will not be cached.

If the CDN controlled is selected, the following will be added to the response headers:

  • Cache-Control. This header specifies the maximum time the object should remain in the local cache as valid. For a 12 hours expiry period, you will see Cache-Control: max-age=43200
  • X-Cached-Since. This header contains the timestamp when the object was initially cached in the CDN cache
  • Expires. This is a timestamp resulting from "NOW()" + Cache-Control->max-age telling the client browser to keep this object in cache for the amount of time specified by the max-age parameter in the Cache-Control header.
  • Cache:HIT or Cache:MISS. This shows if the file was delivered from the CDN cache or had to be pulled from the origin. It’s not relevant to the actual caching.

How to configure the Browser Caching option

1. Go to the CDN resources section.

2. Click the custom domain name of the CDN resource for which you want to configure Browser Caching.

CDN resources tab from where you can open settings

The new page opens. Perform the remaining steps there.

Configure Browser Caching Option

3. Click on the Cache and then select the Browser Caching option.

4. Toggle on Enable browser caching.

5. Select Origin controlled or CDN controlled in the list. If you set Origin controlled, the configuration is complete; continue to step six. If you select CDN controlled, follow the instructions in the expandable block.

Choose one of the options from the list. The recommended value is four days. CDN origin configuration/browser-caching-30.png

You can also choose “Custom value” to set an expiry period not presented in the list. For the custom value, you should specify the expiry period in seconds. For instance, if you want to cache content for one day, you need to enter 86400, as there are 86400 seconds in a day.

CDN origin configuration/browser-caching-40.png

6. Save changes.

Was this article helpful?

Not a Gcore user yet?

Learn more about our next-gen CDN

Go to the product page