{
  "slug": "cache-contentful-delivery-api-edge",
  "title": "Cache contentful delivery api at edge avoid limits",
  "metaTitle": "Cache contentful delivery api at - RealComposer",
  "metaDescription": "Cache contentful delivery api at edge avoid limits. Shield Contentful with 300s GET edge cache; cache key uses query params on.",
  "headline": "Shield Contentful CDN quota on traffic spikes",
  "category": "caching",
  "categoryLabel": "Edge Caching & Rate Limits",
  "urgency": 9,
  "clientPlatform": "Next.js / React",
  "upstreamServices": [
    "Contentful"
  ],
  "searchIntentQuery": "cache contentful delivery api at edge avoid limits",
  "directAnswerSummary": "300s TTL on composed entry responses at Cloudflare edge. For \"cache contentful delivery api at edge avoid limits\", store CONTENTFUL_ACCESS_TOKEN in Secret Vault, call https://cdn.contentful.com/spaces/{{query.spaceId}}/entries from a Worker, and let Next.js / React hit only https://realcomposer.com/v1/workspace/cache-contentful-delivery-api-edge with an rc_live_ client token. Enable 300s GET cache only when query params identify the resource.",
  "problem": {
    "title": "Contentful rate limits from Next.js / React traffic",
    "explanation": "Without edge caching, identical Contentful reads during a session still round-trip to the origin.",
    "risks": [
      "HTTP 429 responses during launch traffic",
      "Surprise SaaS overages from duplicate reads",
      "Slower repeat views than necessary"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Add CONTENTFUL_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Point step contentful at https://cdn.contentful.com/spaces/{{query.spaceId}}/entries with GET. Add output mapping fields that mirror the JSON contract your screen already expects. Set cache TTL to 300s so repeat GETs with the same query string hit caches.default."
    },
    {
      "stepNumber": 3,
      "title": "Call from Next.js / React",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "// app/api route or client component\nconst res = await fetch('https://realcomposer.com/v1/workspace/cache-contentful-delivery-api-edge', {\n  cache: 'no-store',\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Cache contentful delivery api at edge avoid limits",
    "method": "GET",
    "cacheTtlSeconds": 300,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "contentful",
        "upstreamUrlTemplate": "https://cdn.contentful.com/spaces/{{query.spaceId}}/entries",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.CONTENTFUL_ACCESS_TOKEN}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "entryId",
          "sourcePath": "items.0.sys.id",
          "type": "string",
          "sourceStep": "contentful"
        },
        {
          "targetPath": "title",
          "sourcePath": "items.0.fields.title",
          "type": "string",
          "sourceStep": "contentful"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_cache-co",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "cache-contentful-delivery-api-edge"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "entryId": "sample",
    "title": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/cache-contentful-delivery-api-edge\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Is it safe to log Contentful responses in Next.js / React?",
      "answer": "Store CONTENTFUL_ACCESS_TOKEN for cache-contentful-delivery-api-edge. Next.js / React never sees decrypted values."
    },
    {
      "question": "When does edge caching apply to this recipe?",
      "answer": "cache-contentful-delivery-api-edge vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Upstream steps in cache-contentful-delivery-api-edge honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "cache-third-party-api-at-edge",
    "cache-airtable-avoid-rate-limits"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/cache-contentful-delivery-api-edge",
    "markdown": "https://realcomposer.com/recipes/cache-contentful-delivery-api-edge.md",
    "json": "https://realcomposer.com/recipes/cache-contentful-delivery-api-edge.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=cache-contentful-delivery-api-edge&via=agent"
  }
}