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/configuration.md
1# Cache Reserve Configuration23## Dashboard Setup45**Minimum steps to enable:**67```bash8# Navigate to dashboard9https://dash.cloudflare.com/caching/cache-reserve1011# Click "Enable Storage Sync" or "Purchase" button12```1314**Prerequisites:**15- Paid Cache Reserve plan or Smart Shield Advanced required16- Tiered Cache **required** for Cache Reserve to function optimally1718## API Configuration1920### REST API2122```bash23# Enable24curl -X PATCH "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \25-H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" \26-d '{"value": "on"}'2728# Check status29curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/cache/cache_reserve" \30-H "Authorization: Bearer $API_TOKEN"31```3233### TypeScript SDK3435```bash36npm install cloudflare37```3839```typescript40import Cloudflare from 'cloudflare';4142const client = new Cloudflare({43apiToken: process.env.CLOUDFLARE_API_TOKEN,44});4546// Enable Cache Reserve47await client.cache.cacheReserve.edit({48zone_id: 'abc123',49value: 'on',50});5152// Get Cache Reserve status53const status = await client.cache.cacheReserve.get({54zone_id: 'abc123',55});56console.log(status.value); // 'on' or 'off'57```5859### Python SDK6061```bash62pip install cloudflare63```6465```python66from cloudflare import Cloudflare6768client = Cloudflare(api_token=os.environ.get("CLOUDFLARE_API_TOKEN"))6970# Enable Cache Reserve71client.cache.cache_reserve.edit(72zone_id="abc123",73value="on"74)7576# Get Cache Reserve status77status = client.cache.cache_reserve.get(zone_id="abc123")78print(status.value) # 'on' or 'off'79```8081### Terraform8283```hcl84terraform {85required_providers {86cloudflare = {87source = "cloudflare/cloudflare"88version = "~> 4.0"89}90}91}9293provider "cloudflare" {94api_token = var.cloudflare_api_token95}9697resource "cloudflare_zone_cache_reserve" "example" {98zone_id = var.zone_id99enabled = true100}101102# Tiered Cache is required for Cache Reserve103resource "cloudflare_tiered_cache" "example" {104zone_id = var.zone_id105cache_type = "smart"106}107```108109### Pulumi110111```typescript112import * as cloudflare from "@pulumi/cloudflare";113114// Enable Cache Reserve115const cacheReserve = new cloudflare.ZoneCacheReserve("example", {116zoneId: zoneId,117enabled: true,118});119120// Enable Tiered Cache (required)121const tieredCache = new cloudflare.TieredCache("example", {122zoneId: zoneId,123cacheType: "smart",124});125```126127### Required API Token Permissions128129- `Zone Settings Read`130- `Zone Settings Write`131- `Zone Read`132- `Zone Write`133134## Cache Rules Integration135136Control Cache Reserve eligibility via Cache Rules:137138```typescript139// Enable for static assets140{141action: 'set_cache_settings',142action_parameters: {143cache_reserve: { eligible: true, minimum_file_ttl: 86400 },144edge_ttl: { mode: 'override_origin', default: 86400 },145cache: true146},147expression: '(http.request.uri.path matches "\\.(jpg|png|webp|pdf|zip)$")'148}149150// Disable for APIs151{152action: 'set_cache_settings',153action_parameters: { cache_reserve: { eligible: false } },154expression: '(http.request.uri.path matches "^/api/")'155}156157// Create via API: PUT to zones/{zone_id}/rulesets/phases/http_request_cache_settings/entrypoint158```159160## Wrangler Integration161162Cache Reserve works automatically with Workers deployed via Wrangler. No special wrangler.jsonc configuration needed - enable Cache Reserve via Dashboard or API for the zone.163164## See Also165166- [README](./README.md) - Overview and core concepts167- [API Reference](./api.md) - Purging and monitoring APIs168- [Patterns](./patterns.md) - Best practices and optimization169- [Gotchas](./gotchas.md) - Common issues and troubleshooting170