Cache firebase firestore reads at edge
Repeat mobile reads without origin round trips
Edge cache Firestore REST document GETs keyed by document path. For "cache firebase firestore reads at edge", store FIREBASE_ACCESS_TOKEN in Secret Vault, call https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}} from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/cache-firebase-firestore-reads-edge with an rc_live_ client token. Enable 180s GET cache only when query params identify the resource.
Uncached Firebase spikes cost and latency
Every React Native visitor can trigger a fresh Firebase call. Bursts exhaust per-minute quotas even when data changes slowly.
- Thundering herds after cache expiry on the origin
- Analytics skewed by client-side retry storms
- Support tickets blaming "API downtime" during spikes
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Store FIREBASE_ACCESS_TOKEN in the vault. React Native never embeds the raw secret, only a revocable rc_live_ client token.
Configure upstream steps and output mapping
Configure headersTemplate to inject vault secrets, target https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}, and Add output mapping fields that mirror the JSON contract your screen already expects.
Call from React Native
Allowed origins on the token should list every React Native host that calls this URL.
const res = await fetch('https://realcomposer.com/v1/workspace/cache-firebase-firestore-reads-edge', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_cache-fi",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "cache-firebase-firestore-reads-edge"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"docName": "sample",
"fields": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- 180s
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 254 B to 38 B (-85%)
curl -X GET "https://realcomposer.com/v1/workspace/cache-firebase-firestore-reads-edge" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Which Firebase credential belongs in the vault for this pipeline?
Yes for cache-firebase-firestore-reads-edge. Ship only an rc_live_ client token in React Native; RealComposer injects FIREBASE_ACCESS_TOKEN on https://firestore.googleapis.com/v1/projects/{{query.projectId}}/databases/(default)/documents/{{query.collection}}/{{query.docId}}.
What cache key does RealComposer use?
cache-firebase-firestore-reads-edge POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.
How do I rotate upstream credentials?
Upstream steps in cache-firebase-firestore-reads-edge honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this React Native + Firebase Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.