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:
- Navigate to your project in the dashboard at
https://app.edgewrap.pro. - Go to the Performance page and select the Edge Caching tab.
- Scroll down to the Cache Rules section.
- Click the Add Cache Rule button.
- Enter the path pattern (e.g.,
/api/v1/search*) and priority order (rules with lower priority numbers are checked first). - Set the cache duration (TTL in seconds) or check Bypass Cache to skip caching entirely for that path.
- Click Save Rule.
Rule Options
| Param | Type | Description |
|---|---|---|
| pathPattern | string | Glob pattern matching the request path (e.g. '/api/products/*', '/images/*.png'). |
| method | string | HTTP method to apply this rule to. Non-GET requests bypass the cache by default.(default: GET) |
| ttlSec | number | Cache duration in seconds. Set to 0 to bypass caching for this pattern. |
| bypassCache | boolean | If true, skips cache lookup and saves entirely for this path.(default: false) |
| priority | number | Lower 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.