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.

To configure cache settings for dynamic content, see the guide on How to configure Advanced Cache Key for Edge Application.

Creating and applying a cache setting for Edge Application

Section titled 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.
  2. On the top-left corner of the page, go to Products menu, represented by three horizontal lines.
  3. Under the BUILD section, select Edge Application.
  4. Select the application you want to configure or create a new one.
  5. On the Main settings tab, under the Modules section, activate the Application Accelerator switch.
  6. 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 Add Cache Settings button.
  3. Enter an easy to remember name for your cache setting. For example: /target-uri - Cache TTL.
  4. 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.
  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 New Rule button and select Request Phase.

  3. Enter an easy to remember name for your rule.

  4. 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

  5. In the Behavior section, select the Set Cache Policy behavior.

  6. In the argument field, select the /target-uri - Cache TTL cache setting.

  7. 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

Section titled 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 New Rule button and select Request Phase.

  3. Enter an easy to remember name for your rule. For example: /target-uri - Bypass Cache.

  4. 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

  5. In the Behavior section, select the Bypass Cache behavior.

  6. 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.

Learn more about Bypass Cache

Creating a rule to forward cookies from the origin to the user

Section titled 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 New Rule button and select Response Phase.

  3. Enter an easy to remember name for your rule. For example: /target-uri - Forward Cookies.

  4. 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

  5. In the Behavior section, select the Forward Cookies behavior.

  6. Click the Save button.

To forward cookies from the user to the origin, you can create the same rule in the Request phase.

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 Add Cache Settings.
  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, except for a few.
  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