Tiered Cache
Turn on a second cache layer between the data center that answers a request and your origin, choose its topology, and purge it by cache key.
Tiered Cache is a Feature of Cache that adds a second cache layer between the data center that answers a request and your origin. The first layer is the cache of that data center. The second layer sits in the region that the topology of a cache setting selects.
When a request misses the first layer, the data center asks the Tiered Cache layer before the request goes to the origin. A valid copy of the requested object in that layer answers the miss, and the origin receives no request. You turn the layer on per cache setting, and it applies to the objects that setting caches. For how the two layers answer a request, refer to Expiration and freshness.
An answer from the Tiered Cache layer arrives with less latency than one from the origin, and fewer requests reach the origin. The origin handles less load at a lower infrastructure cost. The price is one extra hop on a miss in the first layer. With Application Accelerator on, Tiered Cache also sets a floor of 3 seconds on the time to live (TTL) of the cache setting.
Interfaces
A cache setting turns Tiered Cache on in its modules.cache.tiered_cache object, and the four interfaces below write that object. The table names where the control sits in each one.
| Interface | Where | Value |
|---|---|---|
| Azion Console | The Cache section of the Create Cache Settings drawer, under the Cache Settings tab of an Application in Applications | The Tiered Cache toggle, off on a new setting, and the Tiered Cache Region select, nearest-region by default. Turning the toggle on disables Honor cache policies and selects Override cache behavior |
| Azion API v4 | POST /v4/workspace/applications/{application_id}/cache_settings |
modules.cache.tiered_cache.enabled, true or false, and modules.cache.tiered_cache.topology, nearest-region when the body leaves it out |
| Azion CLI | azion create cache-setting --file with the JSON body |
The same tiered_cache object. The --tiered-caching-enabled flag alone is refused with error 21001 |
azion.config.js |
An entry of the cache array, of type AzionCache |
tieredCache: { enabled, topology } |
Tiered Cache is included on every service plan. For every field of a cache setting, with the title and the fix of each error, refer to Cache settings. For the Console steps that apply a setting to a path, refer to Configure cache policies for an application.
Topology
The topology of a cache setting selects where the Tiered Cache layer holds the objects that setting caches. Azion Console, the API, the CLI JSON body, and azion.config.js accept values such as nearest-region and us-east-1, and the Azion API reference lists every accepted value. A value the API does not accept returns error 10039, Invalid Choice.
TTL
The time to live (TTL) of an object in the Tiered Cache layer is the Max Age of its cache setting, the modules.cache.max_age field. While Tiered Cache and Application Accelerator are both on, that field has a floor of 3 seconds. A new cache setting starts at 60 seconds, the default of Max Age in Azion Console, the API, and the CLI. For example, on an Application with Application Accelerator on, a Max Age of 2 seconds with Tiered Cache on is refused with error 21020. The same setting at 3 seconds is accepted.
The ceiling is the ceiling of the cache TTL itself. For the value and the error past it, refer to Applications limits.
Purge
Real-Time Purge removes an object from the Tiered Cache layer before its TTL ends. The layer is tiered_cache in the API body and in the --layer flag of azion purge. A cache key purge is the only type that reaches it. A URL or wildcard purge with that layer returns error 30001, Invalid Purge Layer For Purge Type.
To remove an object held in both layers, purge Tiered Cache first and then Cache. In that order, the first layer is not refilled from a stale Tiered Cache copy. For the Console, API, and CLI steps, refer to Purge cached content.
Bypass Cache
A rule with the Bypass Cache behavior in Rules Engine affects Azion’s cache and not the Tiered Cache layer. An Application whose cache settings turn Tiered Cache on continues to cache objects in that layer for the Max Age of the cache setting, its modules.cache.max_age field. For the symptom this produces and what to do about it, refer to Troubleshoot Applications.
Observability
Real-Time Metrics carries a Tiered Cache dataset beside its Cache dataset. Real-Time Events carries a Tiered Cache dataset as well. Through GraphQL, you query the data that Tiered Cache transfers. For the query and its response, refer to Query usage data from Tiered Cache.