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
Field | What it does | Sub-options |
---|---|---|
Action | Specifies how to modify the cache ID. |
|
Include Values | With Action set to one of the following:
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. |
|
Require Included Elements | With Action set to one of the following:
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. |
|
Elements to include | With Action set to one of the following:
Specifies the names of the query parameters, cookies, or headers to include or exclude from the cache ID. | |
Variable | With Action set to:
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:
- Add another Cache ID Modifications behavior to your property.
- In the Include the following query parameters field, add a random query string name, such as
ignoredQueryString
. - In the Require Included Elements option, select Not required for caching.
As Akamai will never use the query string, all elements will be ignored.
Updated 6 months ago