> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Specify cache lifetime for user browsers

## What is the browser caching option

The Browser Caching option defines how long content is cached in end users’ browsers. It has two modes: Origin controlled (set on the source site´s configuration) and CDN controlled (set in the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard)).

### 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>
  **Note**

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

### 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 Customer Portal. You can select a value from the list or set a custom value in seconds.

<Note>
  **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.
</Note>

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](https://cdn.gcore.com/) section.
2. Click the custom domain name of the CDN resource for which you want to configure Browser Caching.

<Frame>
  <img src="https://mintcdn.com/gcore/eza8d1iXcR57qhAl/images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/browser-caching-10.png?fit=max&auto=format&n=eza8d1iXcR57qhAl&q=85&s=320341ccb274a57a80e7193b6bebb6af" alt="CDN resources tab from where you can open settings" width="1999" height="954" data-path="images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/browser-caching-10.png" />
</Frame>

The new page opens. Perform the remaining steps there.

<Frame>
  <img src="https://mintcdn.com/gcore/eza8d1iXcR57qhAl/images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/browser-caching-20.png?fit=max&auto=format&n=eza8d1iXcR57qhAl&q=85&s=8fd5705e48251ec5d03fac9e54df47df" alt="Configure Browser Caching Option" width="1999" height="1419" data-path="images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/browser-caching-20.png" />
</Frame>

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.

<Accordion title="Configure CDN controlled mode">
  Choose one of the options from the list. The recommended value is four days.

  <Frame>
    <img src="https://mintcdn.com/gcore/YEFzZ1SR7qzbTX3V/images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/cdn-controlled-cache-expiry.png?fit=max&auto=format&n=YEFzZ1SR7qzbTX3V&q=85&s=efe0cd5c33a87423b3ff6d6913690868" alt="CDN Controlled Cache Expiry" width="1470" height="1388" data-path="images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/cdn-controlled-cache-expiry.png" />
  </Frame>

  You can also choose **Custom value** to set an expiry period not presented in the list. For a custom value, specify the cache expiration time in seconds. For example, to cache content for one day, enter 86400.

  <Frame>
    <img src="https://mintcdn.com/gcore/mnJH0tYVLEfDJ5Az/images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/cdn-controlled-cache-expiry-custom.png?fit=max&auto=format&n=mnJH0tYVLEfDJ5Az&q=85&s=181142243a090cc022957898700fdc0a" alt="CDN Controlled Cache Expiry Custom" width="1467" height="843" data-path="images/docs/cdn/cdn-resource-options/cache/specify-cache-lifetime-for-user-browsers/cdn-controlled-cache-expiry-custom.png" />
  </Frame>
</Accordion>

6. Save changes.
