Configure cache policies for an application
Set how long an object stays cached, bypass the cache for a path, and forward the origin's Set-Cookie header to users.
From Azion Console, you set how long an object stays cached, bypass the cache for a path, and forward the origin’s Set-Cookie header. A cache setting carries the cache policy, and a Rules Engine rule applies it to the requests you choose.
To vary a cached object by a query string argument or by a cookie, refer to Configure Advanced Cache Key.
Prerequisites
- An application. To create one, refer to Applications quickstart.
- Access to Azion Console. Refer to Access Azion Console.
- Application Accelerator can generate usage-related costs. For the rates, refer to Pricing.
Turn on Application Accelerator
A cache setting needs no module, and any application can carry one. Application Accelerator is required for a Max Age below 60 seconds, for cache variation, and for the Bypass Cache and Forward Cookies behaviors. The module is off by default. To turn it on:
Access Azion Console > Applications > your application.
On the Main Settings tab, in the Modules section, turn on Application Accelerator.
The application runs with Application Accelerator. Its cache settings accept a Max Age below 60 seconds, and Bypass Cache and Forward Cookies become available in Rules Engine.
Set the cache TTL for a path
A cache setting holds the time-to-live (TTL) the browser applies and the TTL Azion applies. To create one:
Access Azion Console > Applications > your application, then go to the Cache Settings tab.
In Name, enter a name that identifies the setting. For example: /target-uri - Cache TTL.
Under Browser Cache, select Override cache settings and set the maximum age in seconds.
Under Cache, select Override cache behavior and set Max Age to the number of seconds Azion keeps the object.
The cache setting appears in the Cache Settings tab. The same setting can also vary the cached object by query string or by cookie, which is the Advanced Cache Key feature.
A cache setting takes effect only when a rule applies it. To apply this one to the /target-uri path:
Enter a name for the rule. For example: /target-uri - Cache TTL.
In the Criteria section, select the ${uri} variable.
Enter /target-uri as the argument.
Requests whose URI starts with /target-uri carry the cache setting, at both the browser TTL and the Azion TTL you set. A new rule takes a few minutes to propagate.
Bypass the cache for a path
Bypass Cache stops Azion from caching the origin response for the requests a rule matches. To create the rule:
Access Azion Console > Applications > your application, then go to the Rules Engine tab.
Enter a name for the rule. For example: /target-uri - Bypass Cache.
In the Criteria section, select the ${uri} variable.
Enter /target-uri as the argument.
Requests whose URI starts with /target-uri reach the origin, and Azion stores no response for them. A new rule takes a few minutes to propagate.
For more information, refer to Bypass Cache. For the difference between Bypass Cache and a Max Age of 0 seconds, refer to Cache variation.
Forward cookies from the origin to the user
Forward Cookies sends the origin’s Set-Cookie header to users, including on a cache hit. To create the rule:
Access Azion Console > Applications > your application, then go to the Rules Engine tab.
Enter a name for the rule. For example: /target-uri - Forward Cookies.
In the Criteria section, select the ${uri} variable.
Enter /target-uri as the argument.
Requests whose URI starts with /target-uri return the origin’s Set-Cookie header to the user.
The forwarded header can carry session cookies. To stop a user from receiving the session cookies of another user:
In Name, enter a name that identifies the setting. For example: /target-uri - Private cookies.
Under Application Accelerator, open Cache vary by Cookies and set Behavior to Denylist.
Add each session cookie to the list of cookie names.
The cache setting appears in the Cache Settings tab, and it keeps the listed cookies out of the cache key.
To apply that cache setting to the rule that forwards the cookies:
Select the /target-uri - Forward Cookies rule.
Select the /target-uri - Private cookies cache setting.
The rule forwards the origin’s Set-Cookie header and applies the cache setting. A rule change takes a few minutes to propagate. The same rule can also carry the Bypass Cache behavior.