Black FridayYearly cloud servers from $9.99, renewing at the same price.See deals

Page rules

Override caching, rate limiting, response headers, origin SSL and redirects for URLs that match your conditions.

5 min read Updated Nov 8, 2026

Page rules let you handle URLs that meet certain conditions in a different way. For example, you can cache static assets for longer, turn off caching for an admin area, or redirect an old path to a new address.

Go to CDN → CDN domains, open a domain, then select Page rules.

The Page rules list

What a rule contains

FieldDescription
NameA label to help you identify the rule, such as "Static asset caching"
PriorityFrom 1 to 999. The default is 100
EnabledA disabled rule is kept but not applied
ConditionsOne or more conditions, joined by Match all (AND) or Match any (OR)
ActionsOne or more actions to apply when a request matches

Matching URLs

Page rules use the same condition engine as firewall rules. These fields and operators are the ones most often used to describe URLs:

FieldExample
Path / URI Pathstarts with /static/; regex ^/blog/\d+
File Extensionin list jpg, png, css, js
Hostequals img.example.com (useful when a domain has several hostnames)
Query Stringparameter name utm_source, operator exists
Header / Cookiegive the name, then match its value
Is HTTPS, HTTP Method, Client IP, Country Code, ASN, User Agent, Referernarrow the match by request attributes

The available operators are equals, not equals, contains, does not contain, starts with, ends with, regex, in list, not in list, greater/less than (or equal), exists and does not exist.

Tip

Path matching is case-sensitive. To match a directory, use starts with. It's clearer than a regex and easier to get right.

Actions

Under Action, the panels are grouped like this:

GroupPanels
Cache & deliveryCache, Browser cache, Optimization, Network
SecurityWAF, Rate limiting, Block, Challenge, Allow, Signed URL, CORS, Security headers
OriginOrigin override, Rewrite, Origin request headers, SSL/TLS, Origin shield
ResponseCustom headers, Redirect

The ones used most often:

Action panelWhat it does
CacheCache mode (Automatic, Force caching or Do not cache content) and the cache time for matching URLs. Advanced overrides query string handling, the cache host mode, extra variants and serving stale cache. Responses that can't be cached, such as those with Set-Cookie or no-store, still aren't cached
Browser cacheThe browser cache lifetime for matching URLs
Rate limitingRequests over the limit get 429. To rate-limit by header or cookie, use a firewall rule instead
WAFTurns WAF inspection off for matching requests, which is useful for trusted callback URLs
Origin overrideSends matching requests to a different origin, Host or protocol
RewriteChanges the path sent to the origin. The visitor's URL stays the same
Origin request headersSets or removes request headers sent to the origin
SSL/TLSChanges the SSL mode used to connect to the origin for these URLs. With Force HTTPS on, HTTP requests get a 301 redirect to the same URL over HTTPS
Custom headersAdds or replaces HTTP response headers
RedirectResponds with a redirect to a fixed target URL (301, 302, 307 or 308) without contacting the origin

Settings you leave on Follow domain use the site's own Cache, Optimization and Network settings. Options your plan doesn't include show an upgrade tag.

Create a rule

  1. On Page rules, click Add rule.
  2. Enter a name, change the priority if you need to, and leave Enabled on.
  3. Under Match conditions, add your conditions and choose Match all (AND) or Match any (OR).
  4. Under Action, click Enable on each action panel you want and fill in its settings. Click Remove to drop a panel.
  5. Click OK to save. The rule takes effect at the edge within seconds to a minute.

The Add rule dialog: match conditions and action panels

You can't save a rule unless it has at least one condition and one action.

Example: cache static assets for 7 days

  • Condition: File Extension in list jpg, png, css, js
  • Action: Cache, cache time 604800

Example: don't cache the admin area

  • Condition: Path starts with /admin
  • Action: Cache, mode Do not cache content

When several rules match

A request can match more than one page rule, and the actions of every matching rule are applied together. A redirect or Force HTTPS ends processing immediately, so no further rules run.

Warning

Don't give the same URLs conflicting values in different rules, such as two different cache times. Keep conditions from overlapping, or combine those rules into one.

Rule quota

Your plan may limit how many page rules you can create. If it does, a banner at the top of the page shows your usage, such as "Rule quota: 3/5". When you reach the limit, delete rules you no longer need or upgrade your plan.

API

The page rule endpoints are under /api/user/cdn/rules:

bash
curl -X POST "https://api.yeap.cloud/api/user/cdn/rules/create" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "domain_id": 123,
    "name": "Static assets 7d",
    "priority": 100,
    "enabled": true,
    "settings": {
      "matcher": {"op": "and", "conditions": [
        {"collection": "EXTENSION", "op": "in", "var": ["jpg", "png", "css", "js"]}
      ]},
      "action": {"cache": {"enabled": "on", "ttl": 604800}}
    }
  }'

Other endpoints:

  • List rules: GET /api/user/cdn/rules?domain_id=123
  • Update a rule: POST /api/user/cdn/rules/update, with id in the body
  • Delete a rule: DELETE /api/user/cdn/rules/delete?id=<id>
Was this page helpful?