Advertising disclosure: We may earn a commission from links on this site. Commercial relationships can affect placement. Product facts, limitations, and source dates remain part of our editorial record.

How funding works
Web Hosting

Cloudflare Customize cache: A Guide for Website Owners

Learn how Cloudflare Cache Rules identify static resources, how origin cache headers can prevent caching, and when Edge Cache TTL changes that behavior.

Review sources
Research standard

Facts that can change should include a source and check date. Benchmark claims should state the plan, region, method, and test period.

What Customize cache controls#

If your website uses Cloudflare and you want static resources cached without broadly caching every response, create a Cache Rule that identifies the resources intended to be static. Cloudflare cache stores copies of frequently accessed website content across its network, but a rule match does not always guarantee that a response will be cached.

Identify static resources with a Cache Rule#

Cloudflare documents several ways to identify content that is intended to be static:

Data table from this page
Matching methodExample
Directory/static/
Distinctive file extension.shtml
Query-string markerstatic=true

Choose a pattern that reflects how your site organizes or labels static content. A directory rule can cover files under /static/; an extension rule can target files ending in .shtml; and a query-string rule can identify requests containing static=true.

These examples identify requests for a rule. They do not, by themselves, establish that every matching response is suitable for shared caching. Review the content and the response headers from the origin server before applying a broad caching behavior.

Check the origin server's cache headers#

Cloudflare states that a matching Cache Everything rule may still be overridden by cache instructions from the origin. Cloudflare documents that resources are not cached when the origin sends any of these conditions:

  • Cache-Control: max-age=0
  • Cache-Control: private
  • Cache-Control: no-cache
  • An already-expired Expires header

Consequently, configuring a Cache Rule and checking the origin response are separate parts of the decision. A rule can match the intended path, extension, or query-string marker while the origin's headers still prevent caching.

When Edge Cache TTL changes the behavior#

Cloudflare documents an Edge Cache TTL setting within the rule that can override the listed Cache-Control headers. If a resource is intended to be static but its origin headers prevent caching, review whether an Edge Cache TTL setting is appropriate for that rule.

Before overriding those headers, confirm that the matched responses do not contain private or user-specific content. A private or no-cache instruction may be deliberate, so the decision should be based on the actual response behavior and the content's sharing requirements.

A practical configuration sequence#

  1. Identify the resources that are intended to be static.
  2. Select a matching signal, such as /static/, .shtml, or static=true.
  3. Create a Cloudflare Cache Rule for that signal and choose the applicable caching behavior.
  4. Check whether the origin sends max-age=0, private, no-cache, or an expired Expires header.
  5. If those headers prevent the intended caching behavior, review the rule's Edge Cache TTL setting and confirm that overriding them is safe.

These names and behaviors are specific to Cloudflare. Other hosting or CDN providers may use different rule names, settings, and cache-header behavior.

Sources

  1. Cloudflare: Customize cache Checked 2026-09-27
  2. Cloudflare cache documentation Checked 2026-09-27