Create a cache setting
Create a cache setting on an application and apply it with a rule, from Azion Console, the Azion API, or the Azion CLI.
You create a cache setting on an application from Azion Console, the Azion API v4, or the Azion CLI, and apply it to requests with a Rules Engine rule. A setting holds the TTLs and the variation rules; until a rule names it through the Set Cache Policy behavior, it applies to no request.
For a first cache setting through the Console alone, refer to the Cache quickstart. To vary the cache by a query string argument or a cookie, refer to Configure Advanced Cache Key for an application.
Prerequisites
- An application. To create one, refer to Applications quickstart.
- Access to Azion Console, for the Console procedures. Refer to Access Azion Console.
- A personal token, for the API procedures.
- The Azion CLI installed and authorized, for the CLI procedures.
- Application Accelerator on the application, for a Max Age below 60 seconds or for cache variation.
Create the cache setting through Azion Console
The Create Cache Settings drawer carries every field of a setting. To create one:
Access Azion Console > Applications, then select the application.
In Name, enter a unique, descriptive name.
Under Browser Cache, select one option. Honor cache policies forwards the origin’s Cache-Control and Expires headers to the browser. Override cache settings replaces them with a TTL you enter. No cache disables browser caching, so content is always fetched from the server.
Under Cache, select Honor cache policies to keep the origin’s headers, or Override cache behavior to replace them.
In Max Age, enter the seconds Azion keeps a copy. A new setting carries 60.
With the toggle on, Azion serves an expired copy when a revalidation attempt with the origin fails.
With the toggle on, Azion caches a large object in fragments rather than as one piece.
The toggle adds a second cache layer between Azion’s cache and the origin. It requires Override cache behavior and a Max Age of at least 3 seconds.
The setting appears in the Cache Settings list with its Name, ID, Browser Cache, and Cache. For every field with its type, its default, and its bounds, refer to Cache settings.
Apply the setting with a rule
A rule in the request phase decides which requests the setting covers. To create it:
Under Criteria, select ${uri}, an operator, and the argument that matches the paths to cache.
Under Behaviors, select Set Cache Policy, then select the cache setting.
The rule appears in the list and applies the setting to every request its criteria match.
Create the cache setting through the API
Two requests create the setting and the rule that applies it. To send them:
The API answers with HTTP 201, state set to executed, and the new setting under data:
Replace [CACHE SETTING ID] with the id the response returned:
The API answers with HTTP 202 and the rule with state set to pending, because a new rule propagates before it applies:
The setting now applies to every request whose path starts with the argument. To list the settings of an application, send GET to the same cache_settings path.
Create the cache setting through the Azion CLI
The CLI covers part of the object with flags, and the whole of it with a JSON file. To create a setting from flags:
The object carries the browser cache and the variation fields the flags set, and modules.cache at its defaults: honor and 60.
To create a setting with the fields the flags do not cover, send the request body from a file:
Save the API request body above as cache-setting.json.
The command prints the id of the new setting:
The CLI does not create the rule that applies the setting. Create it through the Console or the API, with either procedure on this page. For every flag, refer to Azion CLI create.