Available settings (2)

Last updated Oct 15, 2026 These are the settings that you can configure when creating a cache rule.

Fields

The fields available for Cache Rule matching expressions in the Expression Builder are:

  • URI Full - http.request.full_uri
  • URI - http.request.uri
  • URI Path - http.request.uri.path
  • URI Query String - http.request.uri.query
  • Cookie - http.cookie
  • Hostname - http.host
  • Referer - http.referer
  • SSL/HTTPS - ssl
  • User Agent - http.user_agent
  • X-Forwarded-For - http.x_forwarded_for
  • Request Headers - http.request.headers
  • Cookie value of - http.request.cookies
  • File extension - http.request.uri.path.extension

If you select the Edit expression option, you can enter additional fields supported by Cache Rules. These fields include:

  • cf.bot_management.score
  • cf.bot_management.ja3_hash
  • cf.bot_management.ja4
  • cf.bot_management.verified_bot
  • cf.bot_management.static_resource
  • cf.bot_management.js_detection.passed
  • cf.bot_management.detection_ids
  • cf.bot_management.tags
  • cf.bot_management.signed_agent
  • cf.bot_management.corporate_proxy
  • ip.src.asnum

Bot Management fields require a Bot Management subscription. For field types, descriptions, and expression syntax, refer to the Fields reference.

Note

Single-file purge may not work as expected if your Cache Rule sets a custom cache key (because the dashboard cannot send the headers or cookies that are part of the key), or if your rule expression matches only GET requests (because purge requests use a different HTTP method internally).

For more information and alternatives, refer to Purge by single-file limitations.

Operators

The operators available for Cache Rule expressions are:

  • wildcard
  • strict wildcard
  • equals
  • does not equal
  • contains
  • does not contain
  • matches regex
  • does not match regex
  • starts with
  • ends with
  • does not start with
  • does not end with
  • is in
  • is not in
  • is in list
  • is not in list

Note

Not all operators are available for every selected field.

Note

The is in list and is not in list operators are available for the Hostname field on Enterprise plans. They allow you to match requests against custom lists — for example, a hostname list containing all the domains you want to apply a particular caching configuration to. Refer to Use lists in expressions for details on using lists in rule expressions.

Cache eligibility

In Cache eligibility, you have the option to select Bypass cache if you want matching requests to not be cached, or Eligible for cache if you want Cloudflare to attempt to cache them.

Bypass cache

When creating a cache rule, you have the option to select Bypass cache if you want matching incoming requests to not be cached. Alternatively, you can use Development Mode, if you want to bypass cache for shorter periods.

Note

When using Custom Cache Rules with a Bypass setting, the response header may return DYNAMIC rather than explicitly indicating a bypass. This occurs because either the asset is originally ineligible for caching or the rule makes it ineligible for caching, even if the origin response is otherwise cacheable.

Eligible for cache settings

When you select Eligible for cache, you can change the configuration settings described below.

Note

If you use cache rules, image transformations, and zone versioning simultaneously, some settings may not be applied correctly.

Edge TTL

Edge Cache TTL refers to the maximum cache time-to-live (TTL), or how long an asset should be considered fresh or available to serve from Cloudflare’s cache in response to requests. This setting has three primary options:

  • Use cache control-header if present, bypass cache if not: If a cache-control header is present on the response, follow its directives. If not, skip caching entirely.
  • Use cache-control header if present, use default Cloudflare caching behavior if not: If a cache-control header is present on the response, follow its directives. If not, cache in accordance with our default edge TTL settings.
  • Ignore cache-control header and use this TTL: Completely ignore any cache-control header on the response and instead cache the response for a duration specified in the timing dropdown.

Additionally, you can select how long you would like a particular matching status code's content to be cached in Cloudflare's global network. In Status Code TTL section you can define the TTL duration for one or more status codes of responses from the origin server. This setting can be applied to a Single code status code, to a Greater than or equal or Less than or equal status code, or to a Range of status codes. Status code TTLs are similar to Ignore cache-control header and use this TTL in that the cache-control header on the response will be ignored in favor of the TTL specified by the cache rule. For more information, refer to Status code TTL.

<details>

<summary>

API information

</summary>

API configuration object name: <code>"edge_ttl"</code>.

API values Configuration
<code>respect_origin</code> Use cache-control header if present, use default <a href="https://developers.cloudflare.com/cache/concepts/default-cache-behavior/">Cloudflare caching behavior</a> if not.
<code>override_origin</code> Ignore cache-control header and use this TTL.
<code>bypass_by_default</code> Use cache control-header if present, bypass cache if not.

API configuration examplejson

"action_parameters": {
    "cache": true,
    "edge_ttl": {
        "status_code_ttl": [
            {
                "status_code_range": {
                    "to": 299
                },
                "value": 86400
            },
            {
                "status_code_range": {
                    "from": 300,
                    "to": 499
                },
                "value": 0  // no-cache
            },
            {
                "status_code_range": {
                    "from": 500
                },
                "value": -1  // no-store
            }
        ],
        "mode": "respect_origin"
    }
}

Refer to <a href="https://developers.cloudflare.com/cache/how-to/cache-rules/create-api/#example-requests">Create a cache rule via API</a> for complete API examples.

</details>

Browser TTL

Browser TTL refers to the maximum cache time-to-live (TTL) that an asset should be considered available to serve from the browser’s cache.

Select if you want to Bypass cache, Respect origin, or Override origin. If you wish to override the browser TTL value, define how long resources cached by client browsers will remain valid from the dropdown menu. For more information, refer to Browser Cache TTL.

<details>

<summary>

API information

</summary>

API configuration object name: <code>"browser_ttl"</code>.

API values for the <code>"mode"</code> property: <code>"respect_origin"</code>, <code>"override_origin"</code>, <code>"bypass_by_default"</code>. <br>

API values for the <code>"default"</code> property (integer): values available depend on your plan. Refer to <a href="https://developers.cloudflare.com/cache/how-to/edge-browser-cache-ttl/#browser-cache-ttl">Browser Cache TTL</a>.

API configuration examplejson

"action_parameters": {
  "cache": true,
  "browser_ttl" : {
    "mode": "override_origin",
    "default": 1000
  }
}

Refer to <a href="https://developers.cloudflare.com/cache/how-to/cache-rules/create-api/#example-requests">Create a cache rule via API</a> for complete API examples.

</details>

Cache Key

Cache keys refer to the criteria that Cloudflare uses to determine how to store resources in our cache. Customizing the Cache Key allows you to determine how Cloudflare can reuse particular cache entries across requests or share the cache entries for more granularity for end users.

There is no explicit length limit for cache keys. However, the total request size (including headers used in the cache key) must not exceed Cloudflare's request limits. Including large values (such as cookies) in the cache key may increase per-request latency. The maximum number of query string parameters in a custom cache key configuration is 100.

Define the request components used to define a custom Cache Key, customizing the following options:

Enterprise customers have these additional options for custom Cache Keys:

  • In the Query string section, you can select All query string parameters, All query string parameters except and enter an exception, No query parameters except and enter the parameters, or Ignore query string (also available for Pay-as-you-go customers).
  • In the Headers section, you can specify header names along with their values. For custom headers, values are optional; however, for the following restricted headers, you must include one to three specific values:
  • accept
  • accept-charset
  • accept-encoding
  • accept-datetime
  • accept-language
  • referer
  • user-agent

To check for a header's presence without including its value, use the Check presence of option. You can also choose whether to Include origin header. - In the Cookie section, you can include cookie names and their values, and check for the presence of another cookie. - In the Host section, you can select Use original host and Resolved host. In the User section, you can select Device type, Country, and Language. Using Resolved host means the Cache Key will contain whatever hostname was used to resolve the origin IP which can be different depending on whether the resolve override feature is on or not.

Note

When URL normalization is enabled, we recommend also enabling Normalize URLs to origin, especially if you are setting custom Cache Keys or using cache by device type, which also modifies the Cache Key. This helps ensure the URL in the Cache Key matches the URL sent to the origin, preventing cache poisoning and ensuring consistent behavior.

<details>

<summary>

API information

</summary>

API configuration object name: <code>"cache_key"</code>.

API values: <code>"ignore_query_strings_order"</code>, <code>"cache_deception_armor"</code>, <code>"cache_by_device_type"</code>, <code>"custom_key"</code> (<code>"header"</code>, <code>"cookie"</code>, <code>"host"</code>, <code>"query_string"</code>, <code>"user"</code>).

API configuration examplejson

"action_parameters": {
  "cache": true,
  "cache_key": {
    "ignore_query_strings_order": true,
    "cache_deception_armor": true,
    "custom_key": {
      "query_string": {
        "include": [
          "*"
        ]
      },
      "header": {
        "include": [
          "header1"
        ],
        "check_presence": [
          "header_1"
        ],
        "contains": {
          "accept-encoding": ["br", "zstd"]
        }
      },
      "cookie": {
        "include": [
          "cookieName1"
        ],
        "check_presence": [
          "cookie_1"
        ]
      },
      "user": {
        "device_type": true,
        "geo": true,
        "lang": true
      },
      "host": {
        "resolved": false
      }
    }
  }
}

Refer to <a href="https://developers.cloudflare.com/cache/how-to/cache-rules/create-api/#example-requests">Create a cache rule via API</a> for complete API examples.

</details>

Cache Reserve Eligibility

Cache Reserve eligibility allows you to specify which website resources should be eligible for our persistent cache called Cache Reserve. If the request matches and also meets eligibility criteria, Cloudflare will write the resource to cache reserve. This requires an add-on cache reserve plan.

This rule can also be used to specify Cache Reserve eligibility for website resources based on their size. For example, by specifying that all assets which are eligible be 100 MB and above, Cloudflare will look for eligible assets at or above 100 MB for Cache Reserve eligibility and only persistently store those assets.

Note

Cloudflare will still enforce the plan-based cacheable file limits when using this configuration.

<details>

<summary>

API information

</summary>

API configuration object name: <code>"cache_reserve"</code>.

API property name for enabling Cache Reserve: <code>"eligible"</code> (boolean).

API configuration examplejson