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:

  1. Access Azion Console > Edge Application.
  2. Select the application you want to configure or create a new one.
  3. On the Main Settings tab, in the Modules section, activate the Application Accelerator switch.
  4. 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:

  1. Navigate to the Cache Settings tab of your application.
  2. Click the + Cache Setting button.
  3. Enter an easy to remember name for your cache setting. For example: /target-uri - Cache TTL.
  4. 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.
  5. 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.
  6. Click the Save button.

Next, you must create a rule to apply the cache settings you’ve created. To do so, follow the steps:

  1. Navigate to the Rules Engine tab of your edge application.
  2. Click the + Rule button.
  3. Enter an easy to remember name for your rule.
  4. Select Request Phase.
  5. 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
  6. In the Behavior section, select the Set Cache Policy behavior.
  7. In the argument field, select the /target-uri - Cache TTL cache setting.
  8. 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:

  1. With the Application Accelerator module active, navigate to the Rules Engine tab of your edge application.
  2. Click the + Rule button.
  3. Enter an easy to remember name for your rule. For example: /target-uri - Bypass Cache.
  4. Select Request Phase.
  5. 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
  6. In the Behavior section, select the Bypass Cache behavior.
  7. 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 reference

Creating 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:

  1. Navigate to the Rules Engine tab of your edge application.
  2. Click the + Rule button.
  3. Enter an easy to remember name for your rule. For example: /target-uri - Forward Cookies.
  4. Select Response Phase.
  5. 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
  6. In the Behavior section, select the Forward Cookies behavior.
  7. 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:

  1. Navigate to the Cache Settings tab.
  2. Create a new setting by clicking + Cache Setting.
  3. Enter an easy to remember name for your cache setting. For example: /target-uri - Private cookies.
  4. Under the Advanced Cache Key section, on Cache by Cookie, select the option Content varies by cookies, with the exception of a few (Blocklist).
  5. List all session cookies you wish to keep private.
  6. Click the Save button.

Finally, to activate the cache setting with the listed private cookies for the /target-uri page:

  1. Go to the Rules Engine tab.
  2. Select the /target-uri - Forward Cookies rule you created in the previous steps.
  3. In the Behavior section, click the + Behavior button.
  4. Select the Set Cache Policy behavior.
  5. In the argument field, select the /target-uri - Private cookies cache policy.
  6. Click the Save button.

You can also combine this feature with the Bypass cache behavior described in the previous section.


Contributors