Cache Google Places Autocomplete API to Reduce Bills
Edge TTL shield for Frontend / Web Google Maps calls
To cache google places autocomplete api to reduce bills, set cacheTtlSeconds on a GET pipeline targeting https://maps.googleapis.com/maps/api/place/autocomplete/json?input={{query.input}}&key={{secrets.GOOGLE_MAPS_API_KEY}}. Identical query strings reuse Cloudflare caches.default before upstream sees traffic.
Uncached Google Maps spikes cost and latency
Every Frontend / Web visitor can trigger a fresh Google Maps 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
Bind vault keys to the Worker
Create GOOGLE_MAPS_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Set headers, mapping, and cache TTL
Point step maps at https://maps.googleapis.com/maps/api/place/autocomplete/json?input={{query.input}}&key={{secrets.GOOGLE_MAPS_API_KEY}} 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 Frontend / Web
Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.
const res = await fetch('https://realcomposer.com/v1/workspace/cache-google-places-api-reduce-bills', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_cache-go",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "cache-google-places-api-reduce-bills"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"description": "sample",
"placeId": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- 300s
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 255 B to 43 B (-83%)
curl -X GET "https://realcomposer.com/v1/workspace/cache-google-places-api-reduce-bills" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
What should Frontend / Web store instead of Google Maps secrets?
Point Frontend / Web at /recipes/cache-google-places-api-reduce-bills edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.
Will Anthropic or Linear prompt bodies be rewritten?
Cache key for cache-google-places-api-reduce-bills: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.
How do I rotate upstream credentials?
Rotate vault secrets for cache-google-places-api-reduce-bills anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + Google Maps Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.