Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/cache-reserve/README.md
1# Cloudflare Cache Reserve23**Persistent cache storage built on R2 for long-term content retention**45## Smart Shield Integration67Cache Reserve is part of **Smart Shield**, Cloudflare's comprehensive security and performance suite:89- **Smart Shield Advanced tier**: Includes 2TB Cache Reserve storage10- **Standalone purchase**: Available separately if not using Smart Shield11- **Migration**: Existing standalone customers can migrate to Smart Shield bundles1213**Decision**: Already on Smart Shield Advanced? Cache Reserve is included. Otherwise evaluate standalone purchase vs Smart Shield upgrade.1415## Overview1617Cache 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.1819## Core Concepts2021### What is Cache Reserve?2223- **Persistent storage layer**: Built on R2, sits above tiered cache hierarchy24- **Long-term retention**: 30-day default retention, extended on each access25- **Automatic operation**: Works seamlessly with existing CDN, no code changes required26- **Origin shielding**: Dramatically reduces origin egress by serving cached content longer27- **Usage-based pricing**: Pay only for storage + read/write operations2829### Cache Hierarchy3031```32Visitor Request33↓34Lower-Tier Cache (closest to visitor)35↓ (on miss)36Upper-Tier Cache (closest to origin)37↓ (on miss)38Cache Reserve (R2 persistent storage)39↓ (on miss)40Origin Server41```4243### How It Works44451. **On cache miss**: Content fetched from origin �� written to Cache Reserve + edge caches simultaneously462. **On edge eviction**: Content may be evicted from edge cache but remains in Cache Reserve473. **On subsequent request**: If edge cache misses but Cache Reserve hits → content restored to edge caches484. **Retention**: Assets remain in Cache Reserve for 30 days since last access (configurable via TTL)4950## When to Use Cache Reserve5152```53Need persistent caching?54├─ High origin egress costs → Cache Reserve ✓55├─ Long-tail content (archives, media libraries) → Cache Reserve ✓56├─ Already using Smart Shield Advanced → Included! ✓57├─ Video streaming with seeking (range requests) → ✗ Not supported58├─ Dynamic/personalized content → ✗ Use edge cache only59├─ Need per-request cache control from Workers → ✗ Use R2 directly60└─ Frequently updated content (< 10hr lifetime) → ✗ Not eligible61```6263## Asset Eligibility6465Cache Reserve only stores assets meeting **ALL** criteria:6667- Cacheable per Cloudflare's standard rules68- Minimum 10-hour TTL (36000 seconds)69- `Content-Length` header present70- Original files only (not transformed images)7172### Eligibility Checklist7374Use this checklist to verify if an asset is eligible:7576- [ ] Zone has Cache Reserve enabled77- [ ] Zone has Tiered Cache enabled (required)78- [ ] Asset TTL ≥ 10 hours (36,000 seconds)79- [ ] `Content-Length` header present on origin response80- [ ] No `Set-Cookie` header (or uses private directive)81- [ ] `Vary` header is NOT `*` (can be `Accept-Encoding`)82- [ ] Not an image transformation variant (original images OK)83- [ ] Not a range request (no HTTP 206 support)84- [ ] Not O2O (Orange-to-Orange) proxied request8586**All boxes must be checked for Cache Reserve eligibility.**8788### Not Eligible8990- Assets with TTL < 10 hours91- Responses without `Content-Length` header92- Image transformation variants (original images are eligible)93- Responses with `Set-Cookie` headers94- Responses with `Vary: *` header95- Assets from R2 public buckets on same zone96- O2O (Orange-to-Orange) setup requests97- **Range requests** (video seeking, partial content downloads)9899## Quick Start100101```bash102# Enable via Dashboard103https://dash.cloudflare.com/caching/cache-reserve104# Click "Enable Storage Sync" or "Purchase" button105```106107**Prerequisites:**108- Paid Cache Reserve plan or Smart Shield Advanced required109- Tiered Cache required for optimal performance110111## Essential Commands112113```bash114# Check Cache Reserve status115curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \116-H "Authorization: Bearer $API_TOKEN"117118# Enable Cache Reserve119curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \120-H "Authorization: Bearer $API_TOKEN" \121-H "Content-Type: application/json" \122-d '{"value": "on"}'123124# Check asset cache status125curl -I https://example.com/asset.jpg | grep -i cache126```127128## In This Reference129130| Task | Files |131|------|-------|132| Evaluate if Cache Reserve fits your use case | README.md (this file) |133| Enable Cache Reserve for your zone | README.md + [configuration.md](./configuration.md) |134| Use with Workers (understand limitations) | [api.md](./api.md) |135| Setup via SDKs or IaC (TypeScript, Python, Terraform) | [configuration.md](./configuration.md) |136| Optimize costs and debug issues | [patterns.md](./patterns.md) + [gotchas.md](./gotchas.md) |137| Understand eligibility and troubleshoot | [gotchas.md](./gotchas.md) → [patterns.md](./patterns.md) |138139**Files:**140- [configuration.md](./configuration.md) - Setup, API, SDKs, and Cache Rules141- [api.md](./api.md) - Purging, monitoring, Workers integration142- [patterns.md](./patterns.md) - Best practices, cost optimization, debugging143- [gotchas.md](./gotchas.md) - Common issues, limitations, troubleshooting144145## See Also146- [r2](../r2/) - Cache Reserve built on R2 storage147- [workers](../workers/) - Workers integration with Cache API148