CDN Cache & Rules
Configure caching policies and page rules to optimize performance.
Cache Policies
Cache TTL
Set how long content is cached at the edge:
| Content Type | Recommended TTL |
|---|---|
| Static assets (JS, CSS, images) | 1 year |
| HTML pages | 1 hour - 1 day |
| API responses | No cache or short |
| Dynamic content | No cache |
Cache Key
Customize what makes a unique cache entry:
- Query String - Include all, some, or ignore
- Headers - Vary by Accept-Language, etc.
- Cookies - Include specific cookies
Page Rules
Create rules to match URL patterns and apply behaviors:
Rule Examples
Force HTTPS:
Match: http://example.com/
Action: Redirect to HTTPS
Bypass cache for API:
Match: /api/
Action: Cache bypass
Cache static files:
Match: .jpg, .png, .css, *.js
Action: Cache for 1 year
Cache Purge
Clear cached content when you update your site:
- Purge URL - Clear specific URLs
- Purge Tag - Clear by cache tag
- Purge All - Clear entire cache (use sparingly)
# Purge via API
curl -X POST https://api.zonecloud.com/v1/cdn/domains/{id}/purge \
-H "Authorization: Bearer YOUR_KEY" \
-d "urls[]=/path/to/file.css"