INTEGRITY Cloudflare Docs

Cache Rules

Use Cache Rules to customize cache settings on Cloudflare. Cache Rules allows you to make adjustments to what is eligible to cache, how long it should be cached and where, as well as trigger specific interactions with Cloudflare's cache and other Rules products for matching requests.

Cache Rules can be created in the dashboard, via API or Terraform.

Rules templates

Cloudflare provides you with rules templates for common use cases.

  1. In the Cloudflare dashboard, go to the Rules Overview page.

    Go to Overview ↗
  2. Select Templates, and then select one of the available templates.

You can also refer to the Examples gallery in the developer docs.

Availability

The following table describes Cache Rules availability per plan.

Free Pro Business Enterprise
Availability Yes Yes Yes Yes
Number of rules 10 25 50 300

Cache Rules and cache keys

When a Cache Rule sets a custom cache key, the resulting cache entry is indexed by that key rather than the request URL alone. Depending on what the custom cache key includes, this may affect single-file purge:

To purge resources that cannot be cleared via dashboard single-file purge, you have the following options:

For more information, refer to Cache keys and Purge cache key resources.

Troubleshooting

When troubleshooting Cache Rules, use Cloudflare Trace to determine if a rule is triggering for a specific URL.