Learn about setting expiration for resources cached in a visitor’s browser.
Overview
Cloudflare caches specific static assets to provide your visitors a fast experience. You can specify a time for a visitor’s Browser Cache TTL in the Cloudflare Caching app. Alternatively, refer to Cloudflare’s documentation on Edge Cache TTL for configuring cache duration within Cloudflare’s data centers.
By default, Cloudflare honors the cache expiration set in your Expires and Cache-Control headers. Cloudflare overrides any Cache-Control or Expires headers with values set via the Browser Cache TTL option in the Cloudflare Caching app if:
- The value of the Cache-Control header from the origin web server is less than the Browser Cache TTL Cloudflare setting, or
- the origin web server does not send a Cache-Control or an Expires header.
Setting Browser Cache TTL
Set the Browser Cache TTL option in the Cloudflare Caching app. To accelerate page load for your repeat visitors, select a high Browser Cache TTL. The Cloudflare UI and API both prohibit setting Browser Cache TTL to 0 for non-Enterprise domains.
- Login to Cloudflare and select the appropriate site.
- Select the Caching app.
- Scroll to Browser Cache TTL and click the drop-down menu to select the desired cache expiration.
The Respect Existing Headers option tells Cloudflare to honor the settings in the Cache-Control headers from your origin web server.
Related resources
- Which file extensions does Cloudflare cache for static content?
- How can I tell if Cloudflare is caching my site or a specific file?
- How do I tell Cloudflare what to cache?
- Enabling Origin Cache-Control with Cloudflare Page Rules
- Getting Started with Cloudflare Caching