Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import FrameBox from '@aziontech/webkit/frame-box'
import ItemList from '@aziontech/webkit/item-list'
import DocItem from '@aziontech/webkit/doc-item'

When the response to one URL depends on a cookie, a device, or a request body, the cache has to tell those requests apart. In an [Application](/en/documentation/platform/applications/), adding those inputs to the cache key requires [Application Accelerator](/en/documentation/platform/applications/application-accelerator/), a Platform Resource that unlocks four capabilities for the cache and the rules. Application Accelerator is off in a new Application, and each Application turns it on separately, in the Application's `modules.application_accelerator.enabled` field in the API. Each [cache setting](/en/documentation/platform/applications/cache/cache-settings/) of the Application holds how long a response stays in cache. It then sets the inputs that make two requests different, in its own `modules.application_accelerator` object. How a variation changes the cache key, with its diagram, is on the [Application Accelerator overview](/en/documentation/platform/applications/application-accelerator/#request-path).
When the response to one URL depends on a cookie, a device, or a request body, the cache has to tell those requests apart. In an [Application](/en/documentation/platform/applications/), adding those inputs to the cache key requires [Application Accelerator](/en/documentation/platform/applications/application-accelerator/), a Platform Resource that unlocks four capabilities for the cache and the rules. Application Accelerator is off in a new Application, and each Application turns it on separately, in the Application's `modules.application_accelerator.enabled` field in the API.

The sections cover what turning on Application Accelerator unlocks, what a variation costs, and how purges reach variations. The last section compares _Bypass Cache_ with a time to live (TTL) of 0.
A [cache setting](/en/documentation/platform/applications/cache/cache-settings/), the set of values that tell Cache how to store and serve a response and for how long, also holds the inputs that make two requests different, in its own `modules.application_accelerator` object. How a variation changes the cache key, with its diagram, is on the [Application Accelerator overview](/en/documentation/platform/applications/application-accelerator/#request-path).

The sections cover what turning on Application Accelerator unlocks, what a variation costs, and how purges reach the copies that variations create. The last section compares _Bypass Cache_ with a time to live (TTL) of 0.

---

Expand All @@ -21,12 +23,14 @@ Turning on Application Accelerator unlocks four capabilities that look unrelated

- Cache variation by query string, by cookie, by device group, and by request method, through [Advanced Cache Key](/en/documentation/platform/applications/cache/cache-settings/#application-accelerator), a Feature of Application Accelerator.
- Caching of `POST` and `OPTIONS` responses, beyond the `GET` and `HEAD` responses an Application caches without it.
- A Max Age as low as 0 seconds, in the `modules.cache.max_age` field of a cache setting, under the 60-second floor that holds without it.
- A Max Age under the 60-second floor, in the `modules.cache.max_age` field of a cache setting.
- More [Rules Engine](/en/documentation/platform/applications/rules-engine/) behaviors, and the `${request_uri}` and `${device_group}` variables in rule criteria. The behaviors are _Add Request Cookie_ and _Add Response Cookie_, _Bypass Cache_, _Capture Match Groups_, _Filter Request Cookie_ and _Filter Response Cookie_, _Forward Cookies_, and _Rewrite Request_.

What the four have in common is dynamic content. Cache variation gives the cache key the extra input it needs to tell two correct responses apart. Caching `POST` and `OPTIONS` responses extends the cache past `GET` and `HEAD`, and a `POST` carries that input in its request body. A TTL under a minute fits content that stops being correct before a minute passes. Several of the gated behaviors act on the cookies and paths that carry the difference in the first place.
What the four have in common is dynamic content. Cache variation gives the cache key the extra input it needs to tell two correct responses apart. Caching `POST` and `OPTIONS` responses extends the cache past `GET` and `HEAD`, and a `POST` carries that input in its request body.

A TTL under a minute fits content that stops being correct before a minute passes. Several of the gated behaviors act on the cookies and paths that carry the difference in the first place.

Application Accelerator is all four or none. An Application takes cache variation only together with the other three capabilities. The API refuses a cache setting that sets a variation on an Application with Application Accelerator off. For the error the API returns, refer to [Cache settings](/en/documentation/platform/applications/cache/cache-settings/#errors).
Application Accelerator is all four or none. The API refuses a cache setting that sets a variation on an Application with Application Accelerator off. For the error the API returns, refer to [Cache settings](/en/documentation/platform/applications/cache/cache-settings/#errors).

Turning on Application Accelerator leaves traffic as it was: the query-string, cookie, and device controls of a cache setting start at `ignore`, and the method list starts empty. A cache setting reaches a request only when a [Set Cache Policy](/en/documentation/platform/applications/rules-engine/#set-cache-policy) behavior applies that cache setting.

Expand All @@ -36,41 +40,49 @@ Turning on Application Accelerator can generate usage-related costs. For more in

## The cost of a variation

Cache variation costs storage first. The cost follows from how the key is built: each distinct value of a varying attribute produces a separate cached object. That makes the choice of what to vary by more consequential than the choice to vary at all. A cookie whose value is unique to each visitor gives every visitor a copy of the object. The cache still works, but each stored response then serves a single visitor. The number of objects grows with the audience instead of with the content.
Cache variation costs storage first. The cost follows from how the key is built: each distinct value of a varying attribute produces a separate copy of the response. That makes the choice of what to vary by more consequential than the choice to vary at all.

A cookie whose value is unique to each visitor gives every visitor a copy of the response. The cache still works, but each stored copy then serves a single visitor. The number of copies grows with the audience instead of with the content.

An allowlist is the control for that cost. The `allowlist` behavior names the query-string arguments or the cookies that change the response, so only an attribute it names can create another copy. The `all` behavior varies by every query-string argument or cookie the request carries.

An allowlist is the control for that cost. The `allowlist` behavior names the query-string arguments or the cookies that change the response, so only an attribute it names can create another object. The `all` behavior varies by every query-string argument or cookie the request carries. For example, a link that arrives with a campaign argument gets its own cached object under `all`. Under an allowlist that does not name that argument, the same link maps to the shared object.
For example, a link that arrives with a campaign argument gets a separate copy under `all`. Under an allowlist that does not name that argument, the same link maps to the shared copy.

Sorting applies the same economy to the order of the arguments. The chosen arguments enter the key in the order the request submitted them, so `?a=1&b=2` and `?b=2&a=1` are two objects that hold one response. With `sort_enabled` on, those variations group under one key, ordered alphabetically. For example, a product listing that changes with its `category` and `page` arguments names both in an allowlist. With `sort_enabled` on, every order of the two arguments reaches one object. The cost of sorting is that the key then differs from the URL as the client wrote it, which matters at purge time. For the Console steps that set these controls, refer to [Configure Advanced Cache Key for an application](/en/documentation/guides/application-performance/cache-and-purge/advanced-cache-key/).
Sorting applies the same economy to the order of the arguments. The chosen arguments enter the key in the order the request submitted them, so `?a=1&b=2` and `?b=2&a=1` are two copies of one response. With `sort_enabled` on, every order of the arguments groups under one key, sorted alphabetically.

For example, a product listing that changes with its `category` and `page` arguments names both in an allowlist. With `sort_enabled` on, every order of the two arguments reaches one copy.

The cost of sorting is that the key then differs from the URL as the client wrote it, which matters at purge time. For the Console steps that set these controls, refer to [Configure Advanced Cache Key for an application](/en/documentation/guides/application-performance/cache-and-purge/advanced-cache-key/).

---

## Cache variation and purges

A purge is a request that removes an object from the cache, and it finds the object by its cache key. A URL purge converts the URL it receives to a cache key without considering content variation. So every variation that the URL does not carry survives it, such as a cookie variation or a device group variation, and its copies stay in the cache.
A purge is a request that removes an object from the cache, and it finds the object by its cache key. A URL purge converts the URL it receives to a cache key without considering content variation. So the copies that a cookie variation or a device group variation creates survive it, because the URL does not carry those inputs.

Two purge types reach them. A cache key purge names each variation, and a wildcard purge ends the key with `@@*`. Query-string variations are the exception, because the query string is part of the URL. A URL purge reaches them when the arguments are sent in the order they were presented, or in alphabetical order when `sort_enabled` is on.
Two purge types reach those copies. A cache key purge names the key of each copy, and a wildcard purge ends the key with `@@*`. Query-string variations are the exception, because the query string is part of the URL. A URL purge reaches their copies when the arguments are sent in the order they were presented, or in alphabetical order when `sort_enabled` is on.

The variations you configure are also the objects a purge has to reach. So a variation with many distinct values costs you at purge time as well as in storage. For the purge types and the steps to run each one, refer to [Real-Time Purge](/en/documentation/platform/applications/cache/real-time-purge/#purge-content-that-varies).
Each copy that a variation creates is also an object a purge has to reach. So a variation with many distinct values costs you at purge time as well as in storage. For the purge types and the steps to run each one, refer to [Real-Time Purge](/en/documentation/platform/applications/cache/real-time-purge/#purge-content-that-varies).

---

## Bypass Cache and a TTL of 0

Without Application Accelerator, the shortest Max Age that a cache setting accepts, in its `modules.cache.max_age` field, is 60 seconds, and the API refuses a lower value. For the error, refer to [Cache settings](/en/documentation/platform/applications/cache/cache-settings/#errors). Application Accelerator removes that floor and allows 0 seconds, or 3 seconds when the cache setting also has [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache/) on. A TTL of 0 differs from not caching, and that difference is why both exist. Both need Application Accelerator, because _Bypass Cache_ is one of the behaviors it unlocks.
Without Application Accelerator, the `modules.cache.max_age` field of a cache setting accepts no value below 60 seconds. For the error the API returns, refer to [Cache settings](/en/documentation/platform/applications/cache/cache-settings/#errors). Application Accelerator removes that floor and allows 0 seconds, or 3 seconds when the cache setting also has [Tiered Cache](/en/documentation/platform/applications/cache/tiered-cache/) on.

The [Bypass Cache](/en/documentation/platform/applications/rules-engine/#bypass-cache) behavior sends every HTTP and HTTPS request its rule matches to the origin, and the response bypasses Azion's own cache. It leaves the browser cache as a _Set Cache Policy_ behavior sets it. Its effect also stops at Azion's own cache: an Application with active Tiered Cache settings keeps caching objects in the Tiered Cache layer for the Max Age of the cache setting. Use it when each request has to receive different content.
A TTL of 0 differs from not caching, and that difference is why both exist. Both need Application Accelerator, because _Bypass Cache_ is one of the behaviors it unlocks.

A Max Age of 0 seconds keeps the request on the cache path: the response carries a cache key and reports `MISS`, and every request still reaches the origin.
The [Bypass Cache](/en/documentation/platform/applications/rules-engine/#bypass-cache) behavior sends every HTTP and HTTPS request its rule matches to the origin, and the response bypasses Azion's own cache. It leaves the browser cache as a _Set Cache Policy_ behavior sets it. Its effect also stops at Azion's own cache: an Application with active Tiered Cache settings keeps caching objects in the Tiered Cache layer for the Max Age of the cache setting. Use it when each request has to receive different content.

Both send every request to the origin. The difference is the cache path: a TTL of 0 keeps the request on it, and _Bypass Cache_ keeps the response out of Azion's cache.
A Max Age of 0 seconds also sends every request to the origin, but it keeps the request on the cache path: the response carries a cache key and reports `MISS`. _Bypass Cache_ keeps the response out of Azion's cache instead.

---

## Related resources

<FrameBox>
<ItemList>
<DocItem title="Application Accelerator settings" href="/en/documentation/platform/applications/application-accelerator/settings/">The controls behind cache variation, cached POST and OPTIONS responses, and a TTL under the floor.</DocItem>
<DocItem title="Application Accelerator settings" href="/en/documentation/platform/applications/application-accelerator/settings/">The controls behind cache variation, cached POST and OPTIONS responses, and a TTL under the 60-second floor.</DocItem>
<DocItem title="Configure Advanced Cache Key for an application" href="/en/documentation/guides/application-performance/cache-and-purge/advanced-cache-key/">The Console steps that set the variation controls of a cache setting, including Sort.</DocItem>
<DocItem title="Cache POST and OPTIONS responses" href="/en/documentation/guides/application-performance/cache-and-purge/cache-post-and-options-responses/">The steps that turn on caching for POST and OPTIONS responses.</DocItem>
<DocItem title="Application Accelerator quickstart" href="/en/documentation/platform/applications/application-accelerator/quickstart/">Application Accelerator turned on and a first cache setting that varies.</DocItem>
Expand Down
Loading
Loading