Cache ID Modification

This behavior controls which query parameters, headers, and cookies form the cache key identifier in addition to the hostname and path.

📘

The Cache ID Modification behavior overrides how nesting usually works within rules. When a rule contains this behavior, any other instances of the behavior specified in a parent rule or prior executing sibling rules no longer apply. When a rule has no Cache ID Modification behavior, the set of behaviors specified in a parent or prior sibling rule determines how to form cache keys for that content.

How it works

Cache ID Modification takes the cache control options beyond regular path, filename, and query parameters. With this behavior enabled, you can add any specific header or cookie values to the cache key. For example, you can use the Accept-Language header to cache different versions of a single URL that's been localized.

Your changes to the cache key don't apply to the two required cache key elements – the hostname, that is either the incoming Host header or the origin hostname, and the path to the object. While these two elements are always part of the cache key, you can use Cache ID Modification to add or remove additional elements in the cache key identifier.

Only the request headers passed from the client can be included in a cache key identifier. You can't use request headers added using the Modify Incoming Request Header behavior or EdgeWorkers to define the cache key. If a request header sent from the client is modified using Modify Incoming Request Header and included in a cache key identifier, the original value sent from the client is used in the cache key.

You can only use variables in a cache key identifier if you set them before the request goes forward to your origin server. For example, you can't use a variable that is extracted from your origin server's response header to define the cache key used when caching the requested content.

Features and options

FieldWhat it doesSub-options
ActionSpecifies how to modify the cache ID.
  • Include the following headers. Includes the specified HTTP request headers in the cache ID.
  • Include the following cookies. Includes the specified cookies in the cache ID.
  • Include all query parameters. Includes all query parameters in the cache ID.
  • Include the following query parameters. Includes only the specified query parameters in the cache ID.
  • Exclude the following query parameters. Excludes the specified query parameters from the cache ID.
  • Include a user-defined variable. Includes a specific user-defined Variable in the cache ID.
  • Include the URL. Includes the full URL.

Include ValuesWith Action set to one of the following:

  • Include the following cookies
  • Include the following query parameters
  • Include the following headers

Select whether to include both the name and the value of the elements as part of the cache ID. If set to No, only the name is used in the cache ID.
  • Yes
  • No
Require Included ElementsWith Action set to one of the following:

  • Include the following cookies
  • Include the following query parameters
  • Include the following headers
  • Exclude the following query parameters

Select whether specified elements are required in order to cache content. When required, if a request lacks the specified elements, the content is not cached. When not required, the content is cached whether or not the element is included in the request.
  • Required for caching
  • Not required for caching
Elements to includeWith Action set to one of the following:

  • Include the following cookies
  • Include the following query parameters
  • Include the following headers
  • Exclude the following query parameters

Specifies the names of the query parameters, cookies, or headers to include or exclude from the cache ID.
VariableWith Action set to:

  • Include a user-defined variable

Select the variable you want to include in the cache key.

Tips and best practices

You can apply several instances of this behavior to a rule to cache various inputs. For example, if you want to include both headers and cookies in the cache ID, you need to add two instances of this behavior, one for each type of input.

You may also want to override any previous instances of this behavior in your rule tree and exclude all query strings, headers, cookies, and variables from the cache key. To do this:

  1. Add another Cache ID Modifications behavior to your property.
  2. In the Include the following query parameters field, add a random query string name, such as ignoredQueryString.
  3. In the Require Included Elements option, select Not required for caching.

As ​Akamai​ will never use the query string, all elements will be ignored.