Rules

Updated at:

ESA rules let you define conditions that control when specific feature configurations take effect.

Use rules to apply configurations for specific needs such as request transformation, content redirection, or cache policies. Rules also support fine-grained security and traffic management. All rules share consistent syntax to filter requests by characteristics and apply the matching configuration.

Simple configuration examples

Set edge cache TTL for a specific path

Static resources under /content update monthly. To balance persistence and freshness, set the cache TTL for /content resources on ESA POPs to 30 days.

  1. Configure the request filter condition:

    • Use console controls: URI Path equals /content

    • Use the expression editor: (http.request.uri.path eq "/content")

  2. Configure the edge cache TTL: Use Custom TTL 30 Days

Redirect requests by region

Redirect requests from the Chinese mainland from example.com to example.com.cn.

  1. Configure the request filter condition:

    • Use console controls: Hostname equals example.com And Country/Region equals China

    • Use the expression editor: (http.host eq "example.com" and ip.geoip.country eq "CN")

  2. Configure the redirect destination URL: Static redirect to https://example.com.cn

Rule configuration structure

When a request reaches an ESA node, ESA filters and processes it based on your rule configuration.

image

Every ESA rule configuration includes two parts:

Rule configuration = Rule expression + Action

Configure a rule expression to filter requests and an action to run on matched requests. The expression syntax is consistent across all rule-related features in ESA, so you can reuse configurations across features. Rule expression structure.

Feature availability by plan

Feature category

Feature

Free

Basic

Standard

Advanced

Enterprise

General rule capabilities

Maximum nested sub-conditions per rule

10

10

15

20

20

Regular expression operator

Not supported

Not supported

Not supported

Supported

Supported

HTTPS rule

SSL/TLS rule, HTTPS rule (shared quota)

5

10

50

75

125

Security rule

5

10

25

50

125

Transform rule

URL rewrite, modify outbound request header, modify outbound response header (shared quota)

5

10

50

75

125

managed transform - real client IP header

Supported

Supported

Supported

Supported

Supported

managed transform - client geolocation header

Supported

Supported

Supported

Supported

Supported

Redirection rule

5

10

50

75

125

Cache rule

cache eligibility, browser cache TTL, edge cache TTL, status code cache TTL, custom cache key (shared quota)

5

10

50

75

125

custom port caching

Not supported

Not supported

Not supported

Not supported

Supported

expired cache response

Supported

Supported

Supported

Supported

Supported

cache reserve

Supported

Supported

Supported

Supported

Supported

Network optimization rule

5(WebSocket configuration is not currently supported)

10

50

75

100

Content optimization rule

file compression, image optimization, video processing (shared quota)

5

10

50

75

100

Origin fetch rule

Maximum rules

5

10

50

75

125

custom origin host

Supported

Supported

Supported

Supported

Supported

origin protocol and port

Supported

Supported

Supported

Supported

Supported

origin SNI

Supported

Supported

Supported

Supported

Supported

DNS record

Supported

Supported

Supported

Supported

Supported

byte-range caching

Supported

Supported

Supported

Supported

Supported

origin HTTP request timeout

Supported

Supported

Supported

Supported

Supported

origin redirect following

Supported

Supported

Supported

Supported

Supported