|
|
3 dagen geleden | |
|---|---|---|
| .. | ||
| README.md | 3 dagen geleden | |
| api.md | 3 dagen geleden | |
| configuration.md | 3 dagen geleden | |
| gotchas.md | 3 dagen geleden | |
| patterns.md | 3 dagen geleden | |
Persistent cache storage built on R2 for long-term content retention
Cache Reserve is part of Smart Shield, Cloudflare's comprehensive security and performance suite:
Decision: Already on Smart Shield Advanced? Cache Reserve is included. Otherwise evaluate standalone purchase vs Smart Shield upgrade.
Cache Reserve is Cloudflare's persistent, large-scale cache storage layer built on R2. It acts as the ultimate upper-tier cache, storing cacheable content for extended periods (30+ days) to maximize cache hits, reduce origin egress fees, and shield origins from repeated requests for long-tail content.
Visitor Request
↓
Lower-Tier Cache (closest to visitor)
↓ (on miss)
Upper-Tier Cache (closest to origin)
↓ (on miss)
Cache Reserve (R2 persistent storage)
↓ (on miss)
Origin Server
Need persistent caching?
├─ High origin egress costs → Cache Reserve ✓
├─ Long-tail content (archives, media libraries) → Cache Reserve ✓
├─ Already using Smart Shield Advanced → Included! ✓
├─ Video streaming with seeking (range requests) → ✗ Not supported
├─ Dynamic/personalized content → ✗ Use edge cache only
├─ Need per-request cache control from Workers → ✗ Use R2 directly
└─ Frequently updated content (< 10hr lifetime) → ✗ Not eligible
Cache Reserve only stores assets meeting ALL criteria:
Content-Length header presentUse this checklist to verify if an asset is eligible:
Content-Length header present on origin responseSet-Cookie header (or uses private directive)Vary header is NOT * (can be Accept-Encoding)All boxes must be checked for Cache Reserve eligibility.
Content-Length headerSet-Cookie headersVary: * header# Enable via Dashboard
https://dash.cloudflare.com/caching/cache-reserve
# Click "Enable Storage Sync" or "Purchase" button
Prerequisites:
# Check Cache Reserve status
curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \
-H "Authorization: Bearer $API_TOKEN"
# Enable Cache Reserve
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value": "on"}'
# Check asset cache status
curl -I https://example.com/asset.jpg | grep -i cache
| Task | Files |
|---|---|
| Evaluate if Cache Reserve fits your use case | README.md (this file) |
| Enable Cache Reserve for your zone | README.md + configuration.md |
| Use with Workers (understand limitations) | api.md |
| Setup via SDKs or IaC (TypeScript, Python, Terraform) | configuration.md |
| Optimize costs and debug issues | patterns.md + gotchas.md |
| Understand eligibility and troubleshoot | gotchas.md → patterns.md |
Files: