---
schema_version: "1"
id: 9eb2e84a4f6ec6b2fd1d8379c02bc79cb1611fd655e283056a7a9dcc4a3518ac
title: Configure Site Caching
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/sites_caching.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.sites_caching.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 42409fb896be6ed0dbd8485ffd0863bb11f1f64bdd5c13861f25d7c2ac6a5e52
description: Caching your Salesforce Site pages, attachments, and static resources can improve page load times and site performance. It can also help you avoid reaching bandwidth and service request time limits.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Configure Site Caching

Caching your Salesforce Site pages, attachments, and static resources can improve page load times and site performance. It can also help you avoid reaching bandwidth and service request time limits.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Developer</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> Editions</td></tr></tbody></table>

To optimize content delivery to your end users, you can enable or disable caching and set the cache duration for each of your site’s pages, attachments, and static resources.

## Caching Behavior for Static Site Resources

Static site resources such as images, style sheets, and scripts are cached based on the `Cache Control` attribute on the resource. For more information, see [Define Static Resources](https://help.salesforce.com/s/articleView?id=platform.pages_static_resources_create.htm&type=5&language=en_US) in Salesforce Help.

## Caching Behavior for Attachments

For attachments stored in Experience Cloud sites and Salesforce Sites, the caching behavior varies based on the type of attachment.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:40%">
          <col style="width:40%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e102">Attachment Type</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e105">Caching Behavior</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e108">Caching Location</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Attachment Type" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e102 ">Documents and attachments</td>

            <td data-label="Caching Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e105 ">The cache expires according to <code>maxage</code> parameter, in seconds. For example:
              <samp class="filepath">/servlet/servlet.FileDownload?file=&lt;FileID&gt;&amp;maxage=600</samp>
            </td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e108 ">End user’s web browser</td>

          </tr>
          <tr class="">
            <td data-label="Attachment Type" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e102 ">Images in a rich text area</td>

            <td data-label="Caching Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e105 ">The cache expires in 45 days.</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e108 ">
              <p>Unauthenticated guest users without IP restrictions: Proxy
                server</p>
              <p style="margin-bottom:0;">Guest users with IP restrictions and authenticated
                users: end user’s web browser</p>
            </td>

          </tr>
        </tbody>
      </table>

## Site-Level Caching Option for Public Visualforce Pages

To control whether a site’s public Visualforce pages are cached, set the site-level setting **Cache public Visualforce pages**. This setting is enabled by default for new sites.

When that site-level setting is enabled:

- Proxy servers cache the publicly accessible Visualforce page responses only during page visits by unauthenticated guest users.
- The caching behavior and caching location for publicly accessible Visualforce pages differ based upon whether IP range restrictions or login hours restrictions are defined for the site's guest user.
- If caching occurs at the network level, when a page is cacheable for guest users, an unauthenticated version of that page can be served to authenticated users. Examples of options that can cache your site pages at the network level include content delivery networks (CDNs) and intercepting proxy servers, such as a data loss prevention (DLP) proxy. This behavior can also occur when a custom domain uses the [Salesforce CDN](https://help.salesforce.com/s/articleView?id=platform.domain_mgmt_salesforce_cdn.htm&type=5&language=en_US) or [your HTTPS certificate](https://help.salesforce.com/s/articleView?id=platform.domain_mgmt_cert.htm&type=5&language=en_US) to serve your site.
- You can disable caching for an individual publicly accessible Visualforce page. To disable that caching, set the page’s boolean `cache` attribute to `false`.

When the site-level setting is disabled:

- The proxy server doesn’t cache any of the site’s Visualforce pages. Instead, the site’s cache-enabled Visualforce pages are cached in the web browser for both authenticated and unauthenticated users. This caching behavior matches caching for Visualforce pages served by Salesforce outside of a site.
- You can enable caching for an individual publicly accessible Visualforce page. To enable that caching, set the page’s boolean `cache` attribute to `true`.

## Page-Level Caching Options for Public Visualforce Pages

To control the caching behavior for your site’s Visualforce pages, set the boolean `cache` attribute and the integer `expires` attribute on each page.

For example, a Visualforce page whose cache is set to expire in 15 minutes looks like this:

```markup
<apex:page cache="true" expires="900">
```

## Caching Behavior for Visualforce Pages When Site-Level Caching Is Enabled

Here are the rules for caching when the site-level Cache public Visualforce pages setting is enabled.

- The page is cached only when the page-level `cache` attribute is `true` or when that attribute isn’t set.
- The caching behavior and location also differ based upon whether IP range restrictions or login hours restrictions are defined for the site's guest user.
- When caching occurs in these cases, the cache expires based on the page's `expires` attribute. If the page’s `expires` attribute isn’t set, the cache expires in 600 seconds (10 minutes).

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:25%">
          <col style="width:25%">
          <col style="width:25%">
          <col style="width:25%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e282">Event</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e285">Page-Level <code>cache</code>
              Attribute</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e291">Site Guest User Restrictions</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e294">Caching Location</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Event" class="slds-cell-wrap" rowspan="3" style="vertical-align:top;" headers="d198835e282 ">An unauthenticated user visits a login-enabled
              site.</td>

            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e285 "><code>true</code>, <code>false</code>, or not set</td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">Yes</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Not cached</td>

          </tr>
          <tr class="">
            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e285 "><code>true</code> or not set</td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">No</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Proxy server and end user’s web browser</td>

          </tr>
          <tr class="">
            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e285 ">
              <code>false</code>
            </td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">No</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Not cached</td>

          </tr>
          <tr class="">
            <td data-label="Event" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e282 ">An authenticated user visits a login-enabled site.</td>

            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e285 "><code>true</code>, <code>false</code>, or not set</td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">Yes or No</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Not cached</td>

          </tr>
          <tr class="">
            <td data-label="Event" class="slds-cell-wrap" rowspan="3" style="vertical-align:top;" headers="d198835e282 ">A user visits a Salesforce Site that isn’t
              login-enabled.</td>

            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" rowspan="2" style="vertical-align:top;" headers="d198835e285 "><code>true</code> or not
              set</td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">Yes</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">End user’s web browser</td>

          </tr>
          <tr class="">
            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">No</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Proxy server and end user’s web browser</td>

          </tr>
          <tr class="">
            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e285 ">
              <code>false</code>
            </td>

            <td data-label="Site Guest User Restrictions" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e291 ">Yes or No</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e294 ">Not cached</td>

          </tr>
        </tbody>
      </table>

## Caching Behavior for Visualforce Pages When Site-Level Caching Is Disabled

When the site-level Cache public Visualforce pages setting is disabled, you can enable caching for specific pages via the page-level cache attribute. When that attribute is `true`, the Visualforce page is cached in the end user's web browser and the cache expires according to the page’s expires attribute. If the page’s `expires` attribute isn’t set, the cache expires in 0 seconds.

This behavior applies to both authenticated and unauthenticated users regardless of whether the site is login-enabled. Also, the presence of IP range restrictions or work hour restrictions on the site’s guest user has no impact on this caching behavior.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
          <col style="width:33.33333333333333%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e448">Event</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e451">Page-Level <code>cache</code>
              Attribute</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d198835e457">Caching Location</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Event" class="slds-cell-wrap" rowspan="2" style="vertical-align:top;" headers="d198835e448 ">A user visits a site.</td>

            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e451 ">
              <code>true</code>
            </td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e457 ">End user’s web browser</td>

          </tr>
          <tr class="">
            <td data-label="Page-Level cache Attribute" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e451 "><code>false</code> or not set</td>

            <td data-label="Caching Location" class="slds-cell-wrap" style="vertical-align:top;" headers="d198835e457 ">Not cached</td>

          </tr>
        </tbody>
      </table>

#### See Also

- [Salesforce Sites Usage and Billing](https://help.salesforce.com/s/articleView?id=platform.sites_limits.htm&release=264.0.0&type=5 "Salesforce Sites usage is governed by monthly and daily allocations. Understanding these allocations is important to the success of your sites.")
- [Define Static Resources](https://help.salesforce.com/s/articleView?id=platform.pages_static_resources_create.htm&type=5&language=en_US)