All Products
Search
Document Center

Edge Security Acceleration:Rules

Last Updated:Mar 25, 2025

Edge Security Acceleration (ESA) lets you create rules to customize settings for incoming requests. To apply custom settings like transform, redirect, or cache to specific requests, or to gain detailed control over security and traffic management, use syntax and configuration logic to filter requests based on specific characteristics and configure the appropriate features.

Understanding rules by basic examples

Set an edge cache time-to-live (TTL) for resources in a specific directory

For example, static resources in the /content directory are configured to update on a monthly basis. To balance the durability and timeliness of resources, adjust the TTL of the resources in the /content directory on ESA points of presence (POPs) to 30 days.

  1. Use one of the following methods to configure a rule expression:

    • Use the expression builder: image

    • Use the expression editor:

      (http.request.uri.path eq "/content")
  2. Configure the edge cache TTL: image

Set a redirect rule to redirect certain requests

For example, redirect requests from the Chinese mainland from example.com to example.com.cn.

  1. Use one of the following methods to configure a rule expression:

    • Use the expression builder: image

    • Use the expression editor:

      (http.host eq "example.com" and ip.geoip.country eq "CN")
  2. Configure the destination URL: image

How rules work

When a request reaches the ESA POP, ESA filters the request based on your rule configuration and processes it accordingly.

image

An ESA rule comprises two parts:

Rule configuration = Rule expression + Action

You can configure a rule expression to filter requests and action to perform actions on matched requests. The syntax of rule expressions applies to all ESA rule configurations.

Priorities

  • Rule configurations have a higher priority than global settings: For the same feature, the rule takes precedence over global settings. Therefore, you can configure global settings for broad application across all requests, while also configuring rules for customized settings tailored to particular requests.

    image

    If you have set Edge Cache TTL to 12 hours and configured the edge cache TTL for the /content directory to 30 days, the TTL for the /content directory is changed to 30 days accordingly. If the requested resource is not in the /content directory, its TTL is still 12 hours.

    image
  • The rule at the top has the highest priority: For the same feature, the rules are executed from top to bottom. Therefore, if a request meets the trigger conditions defined in multiple rules simultaneously, promote the rule you want to prioritize by dragging image.

    Note

    Each plan supports different features and rules. For more information, see Select a suitable plan.

    For example, if you have two cache rules:

    Rule 1: The TTL of resources in the /content directory is 30 days.
    Rule 2: The TTL of files with the suffix .jpg is 60 days.
    • In the following figure, Rule 1 is positioned at the top, with Rule 2 below it.

      image

      The following table lists the TTL for different resources on POPs.

      Sample URI

      In the /content directory or not

      .jpg suffix

      TTL

      https://example.com/content/static/pic.jpg

      p442272.png

      p442272.png

      30 days

      https://example.com/content/static/book.txt

      p442272.png

      ×

      30 days

      https://example.com/static/pic.jpg

      ×

      p442272.png

      60 days

      https://example.com/static/res/book.text

      ×

      ×

      Do not cache it.

    • In the following figure, Rule 2 is positioned at the top, with Rule 1 below it.image

      The following table lists the TTL for different resources on POPs.

      Sample URI

      In the /content directory or not

      .jpg suffix

      TTL

      https://example.com/content/static/pic.jpg

      p442272.png

      p442272.png

      60 days

      https://example.com/content/static/book.txt

      p442272.png

      ×

      30 days

      https://example.com/static/pic.jpg

      ×

      p442272.png

      60 days

      https://example.com/static/res/book.text

      ×

      ×

      Do not cache it.

Availability

Rule

Entrance

Pro

Premium

Enterprise

Security rules

10

25

50

125

Browser cache TTL

2 hours

1 hour

1 second

1 second

Edge cache TTL

2 hours

1 hour

1 second

1 second

Custom port cache

×

×

×

p442272.png

Cache reserve

×

×

×

p442272.png

Redirect rules

10

25

50

125

Network optimization rules

10

25

50

100

File compression rules

×

×

×

10