Cache variation
See what Application Accelerator unlocks, what each cache variation costs, how purges reach varied objects, and how a TTL of 0 differs from Bypass Cache.
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, Application Accelerator is a Platform Resource that adds those inputs to the cache key. It 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 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.
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.
What Application Accelerator unlocks
Turning on Application Accelerator unlocks four capabilities that look unrelated until you see what they have in common:
- Cache variation beyond the URL, by query string, by cookie, by device group, and by request method. The feature is named Advanced Cache Key.
- Caching of
POSTandOPTIONSresponses, beyond theGETandHEADresponses an Application caches without it. - A Max Age as low as 0 seconds, in the
modules.cache.max_agefield of a cache setting, under the 60-second floor that holds without it. - More 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 brings in the methods that carry that input in the 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 extra methods and behaviors. 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.
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 behavior applies it.
Turning on Application Accelerator can generate usage-related costs. For more information, refer to Pricing.
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.
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.
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.
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.
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.
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.
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. Application Accelerator removes that floor and allows 0 seconds, or 3 seconds when the cache setting also has 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.
The Bypass Cache behavior sends every HTTP and HTTPS request its rule matches to the origin, and the response bypasses Azion’s own cache. It keeps protocol optimizations and, where possible, a keep-alive connection to the origin. 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 minimum TTL. Use it when each request has to receive different content.
A Max Age of 0 seconds keeps the request on the cache path. Parallel requests for the same object reach the origin as one request, and Azion validates the object with an If-Modified-Since request. An object that has not changed is not transferred again, and the answer can be a 304 Not Modified. A Max Age of 0 still creates a cache object, which lives for 999 milliseconds. Use it when dynamic content can be delivered identically to everyone who requests it at the same moment.
The trade is between freshness for each request and load on the origin. Bypass Cache gives every request its own answer. In exchange, it gives up the single origin request for parallel requests and the revalidation that skips an unchanged transfer. A TTL of 0 keeps both, and gives up the ability to answer two simultaneous requests differently.