How to configure cache policies for Edge Application
Azion Edge Application can keep your content cached at the edge to support high-levels of demand without compromising quality or performance, resulting in a better user experience, faster load times, and lower maintenance costs.
You can optimize processing times by defining the time-to-live (TTL) for cached content at the origin and at the browser, bypass origin cache settings, and forward cookies with Rules Engine.
Creating and applying a cache setting for Edge Application
In order to customize cache policies, you must first enable the Application Accelerator module to extend the capabilities of Rules Engine. This will also allow you to change the cache TTL to values under 60 seconds.
To enable Application Accelerator, follow the steps:
- Access Azion Console > Edge Application.
- Select the application you want to configure or create a new one.
- On the Main Settings tab, in the Modules section, activate the Application Accelerator switch.
- Click the Save button.
- Access Real-Time Manager (RTM).
- On the top-left corner of the page, go to Products menu, represented by three horizontal lines.
- Under the BUILD section, select Edge Application.
- Select the application you want to configure or create a new one.
- On the Main Settings tab, under the Modules section, activate the Application Accelerator switch.
- Click the Save button.
Now it’s time to create a cache setting and customize cache policies. This is the point where you define how long you want your static content to remain in cache.
To create a new cache setting, follow the steps:
- Navigate to the Cache Settings tab of your application.
- Click the + Cache Setting button.
- Enter an easy to remember name for your cache setting. For example:
/target-uri - Cache TTL
. - In the Cache Expiration Policies section, you can customize your cache’s TTL as follows:
- Under Browser Cache Settings, select Override Cache Settings to define how long your content can be cached in browsers.
- Under Edge Cache Settings, select Override Cache Settings to define how long your content can be cached at the edge.
- If you’ve chosen to override cache settings, add the desired Maximum TTL in seconds.
- At this point, you may also customize other cache settings for dynamic content provided by the Advanced Cache Key feature.
- Click the Save button.
- Navigate to the Cache Settings tab of your application.
- Click the Add Cache Settings button.
- Enter an easy to remember name for your cache setting. For example:
/target-uri - Cache TTL
. - In the Expiration Settings, you can customize your cache’s TTL as follows:
- Under Browser Cache Settings, select Override Cache Settings to define how long your content can be cached in browsers.
- Under CDN Cache Settings, select Override Cache Settings to define how long your content can be cached at the edge.
- If you’ve chosen to override cache settings, add the desired Maximum TTL in seconds.
- At this point, you may also customize other cache settings for dynamic content provided by the Advanced Cache Key feature.
- Click the Save button.
Next, you must create a rule to apply the cache settings you’ve created. To do so, follow the steps:
- Navigate to the Rules Engine tab of your edge application.
- Click the + Rule button.
- Enter an easy to remember name for your rule.
- Select Request Phase.
- In the Criteria section, set the desired criteria that will trigger the rule. To apply the cache settings to a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Set Cache Policy behavior.
- In the argument field, select the
/target-uri - Cache TTL
cache setting. - Click the Save button.
- Navigate to the Rules Engine tab of your edge application.
- Click the New Rule button and select Request Phase.
- Enter an easy to remember name for your rule.
- In the Criteria section, set the desired criteria that will trigger the rule. To apply the cache settings to a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Set Cache Policy behavior.
- In the argument field, select the
/target-uri - Cache TTL
cache setting. - Click the Save button.
Done. The cache settings you created will now be applied to the condition defined in the criteria. You can customize the rule further to suit the business needs of your application.
Creating a rule to bypass cache from the origin
If you want to bypass origin cache policies, you can create a rule as follows:
- With the Application Accelerator module active, navigate to the Rules Engine tab of your edge application.
- Click the + Rule button.
- Enter an easy to remember name for your rule. For example:
/target-uri - Bypass Cache
. - Select Request Phase.
- In the Criteria section, set the desired criteria that will trigger the rule. To bypass cache from a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Bypass Cache behavior.
- Click the Save button.
- With the Application Accelerator module active, navigate to the Rules Engine tab of your edge application.
- Click the New Rule button and select Request Phase.
- Enter an easy to remember name for your rule. For example:
/target-uri - Bypass Cache
. - In the Criteria section, set the desired criteria that will trigger the rule. To bypass cache from a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Bypass Cache behavior.
- Click the Save button.
Bypass Cache only affects origin cache policies, not browser cache policies. You can customize browser cache through the Set Cache Policy behavior described above.
Go to Bypass Cache referenceCreating a rule to forward cookies from the origin to the user
If you want to forward the contents of the Set-Cookie
header to your user, you can create a rule as follows:
- Navigate to the Rules Engine tab of your edge application.
- Click the + Rule button.
- Enter an easy to remember name for your rule. For example:
/target-uri - Forward Cookies
. - Select Request Phase.
- In the Criteria section, set the desired criteria that will trigger the rule. To forward cookies from a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Forward Cookies behavior.
- Click the Save button.
- Navigate to the Rules Engine tab of your edge application.
- Click the New Rule button and select Response Phase.
- Enter an easy to remember name for your rule. For example:
/target-uri - Forward Cookies
. - In the Criteria section, set the desired criteria that will trigger the rule. To forward cookies from a specific URI:
- If
${uri}
starts with/target-uri
- If
- In the Behavior section, select the Forward Cookies behavior.
- Click the Save button.
Note that session cookies may be included in the Forward Cookies behavior. To prevent users from receiving cookies from private sessions:
- Navigate to the Cache Settings tab.
- Create a new setting by clicking + Cache Setting.
- Enter an easy to remember name for your cache setting. For example:
/target-uri - Private cookies
. - Under the Advanced Cache Key section, on Cache by Cookie, select the option Content varies by cookies, with the exception of a few (Blocklist).
- List all session cookies you wish to keep private.
- Click the Save button.
- Navigate to the Cache Settings tab.
- Create a new setting by clicking Add Cache Settings.
- Enter an easy to remember name for your cache setting. For example:
/target-uri - Private cookies
. - Under the Advanced Cache Key section, on Cache by Cookie, select the option Content varies by cookies, with the exception of a few (Blocklist).
- List all session cookies you wish to keep private.
- Click the Save button.
Finally, to activate the cache setting with the listed private cookies for the /target-uri
page:
- Go to the Rules Engine tab.
- Select the
/target-uri - Forward Cookies
rule you created in the previous steps. - In the Behavior section, click the + Behavior button.
- Select the Set Cache Policy behavior.
- In the argument field, select the
/target-uri - Private cookies
cache policy. - Click the Save button.
- Go to the Rules Engine tab.
- Select the
/target-uri - Forward Cookies
rule you created in the previous steps. - In the Behavior section, click the + Behavior button.
- Select the Set Cache Policy behavior.
- In the argument field, select the
/target-uri - Private cookies
cache policy. - Click the Save button.
You can also combine this feature with the Bypass cache behavior described in the previous section.