Cache contentful delivery api at edge avoid limits
Shield Contentful CDN quota on traffic spikes
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.
Contentful rate limits from Next.js / React traffic
Without edge caching, identical Contentful reads during a session still round-trip to the origin.
- HTTP 429 responses during launch traffic
- Surprise SaaS overages from duplicate reads
- Slower repeat views than necessary
How RealComposer Solves This at the Edge
Store upstream credentials in Secret Vault
Add CONTENTFUL_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.
Configure upstream steps and output mapping
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.
Call from Next.js / React
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
// app/api route or client component
const res = await fetch('https://realcomposer.com/v1/workspace/cache-contentful-delivery-api-edge', {
cache: 'no-store',
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"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"
}
}
}
{
"entryId": "sample",
"title": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- 300s
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 253 B to 37 B (-85%)
curl -X GET "https://realcomposer.com/v1/workspace/cache-contentful-delivery-api-edge" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Is it safe to log Contentful responses in Next.js / React?
Store CONTENTFUL_ACCESS_TOKEN for cache-contentful-delivery-api-edge. Next.js / React never sees decrypted values.
When does edge caching apply to this recipe?
cache-contentful-delivery-api-edge vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.
Can I restrict which domains call this pipeline?
Upstream steps in cache-contentful-delivery-api-edge honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this Next.js / React + Contentful Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.