Cache Rules

Override default caching behavior for specific paths or endpoints using per-path cache rules.

Why Cache Rules?

While global configuration controls general caching parameters, different API endpoints have different cache requirements. For instance, static assets (/static/*) can be cached for days, while search endpoints (/search) should have a lower TTL, and user dashboards (/dashboard/*) must bypass the cache entirely.

Dashboard Setup & Configuration

You can create and manage Cache Rules directly inside the EdgeWrap Dashboard:

  1. Navigate to your project in the dashboard at https://app.edgewrap.pro.
  2. Go to the Performance page and select the Edge Caching tab.
  3. Scroll down to the Cache Rules section.
  4. Click the Add Cache Rule button.
  5. Enter the path pattern (e.g., /api/v1/search*) and priority order (rules with lower priority numbers are checked first).
  6. Set the cache duration (TTL in seconds) or check Bypass Cache to skip caching entirely for that path.
  7. Click Save Rule.

Rule Options

ParamTypeDescription
pathPatternstringGlob pattern matching the request path (e.g. '/api/products/*', '/images/*.png').
methodstringHTTP method to apply this rule to. Non-GET requests bypass the cache by default.(default: GET)
ttlSecnumberCache duration in seconds. Set to 0 to bypass caching for this pattern.
bypassCachebooleanIf true, skips cache lookup and saves entirely for this path.(default: false)
prioritynumberLower numbers indicate higher priority. Rules are executed in ascending order.(default: 100)

API Configuration

Alternatively, you can manage Cache Rules programmatically:

Create cache rule via API
curl -X POST https://server.edgewrap.pro/v1/projects/prj_01jxyz/cache/rules \
  -H "Authorization: Bearer <your_session_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "pathPattern": "/api/v1/search*",
    "ttlSec": 3600,
    "bypassCache": false,
    "priority": 10
  }'
Note: If a request matches multiple rules, only the rule with the lowest priority value is applied.