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 Examples: A Guide for Website Owners

Learn how Cloudflare Cache Rules control browser and edge caching, cookies, devices, query strings, cache keys, and content refreshes.

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.

If you need to decide what Cloudflare caches, how long it stays cached, and how visitors receive updated content, Cloudflare’s Cache Rules examples provide documented patterns for website owners. They cover browser and edge cache duration, cookies, devices, query strings, cache keys, status codes, origin cache instructions, and strong ETags.

What caching controls#

Cloudflare describes caching as storing copies of frequently accessed content, such as images, videos, and webpages, in distributed data centers. Cache Rules let you specify which resources Cloudflare caches and how long they remain cached.

For a website owner, the decision is mainly about reuse and freshness:

  • Identify resources that can be served from a cached copy.
  • Set how long a browser or Cloudflare edge location may reuse that copy.
  • Account for request details that may change the response, such as cookies, devices, or query strings.
  • Decide how Cloudflare should treat cache keys, response status codes, origin cache instructions, and strong ETags.

These examples are Cloudflare-specific configuration guidance. Their behavior depends on the settings you choose and on the site’s request patterns, so apply a rule only when the matching requests and acceptable freshness period are clear.

Examples of decisions to make#

Data table from this page
Website needCloudflare example area to review
Keep a copy in a visitor’s browser for a defined periodBrowser cache duration
Control how long content remains available at Cloudflare’s edgeEdge cache duration
Treat requests differently when they contain particular cookiesCookie-based behavior
Vary handling for different device typesDevice-based behavior
Decide whether query strings affect cached contentQuery strings
Define which request properties distinguish one cached response from anotherCache keys
Handle responses according to their status codesStatus codes
Follow instructions sent by the origin serverOrigin cache instructions
Use entity tags when validating whether content changedStrong ETags

Refreshing content after a change#

Caching is also a content-management decision. If a cached file is still valid under the rule, visitors may receive the stored copy until the configured caching period ends. When content changes and a fresh version is needed sooner, Cloudflare documents purge controls for removing cached files and requesting fresh versions from the website server.

Before changing or purging a rule, identify the affected resources and confirm what should be refreshed. A shorter cache duration can reduce the time stale content remains available, while a purge is the documented control for removing cached files when an immediate refresh is required.

A practical review sequence#

  1. List the images, videos, webpages, or other responses you want Cloudflare to cache.
  2. Separate content that can be reused from content that depends on cookies, devices, query strings, or other request details.
  3. Choose browser and edge cache durations that fit how often each resource changes.
  4. Review cache keys, status-code handling, origin cache instructions, and strong ETag behavior for the affected requests.
  5. Test the rule against the request patterns your site actually receives.
  6. When content changes, use the documented purge controls if waiting for the existing cache period is not appropriate.

Cloudflare’s examples explain the available configuration patterns; they do not establish one cache policy for every website. The suitable rule depends on the resource, the request, the required freshness, and how the origin server supplies cache instructions.

Sources

  1. Cloudflare: Examples Checked 2026-10-24
  2. Cloudflare cache documentation Checked 2026-10-24