How to Cache Shopify Storefront API Queries
Shopify GET traffic cached ahead of rate limits
Shopify rate limits hit fast from Frontend / Web. Cache 300s on GET calls where the query string scopes the response.
Shopify rate limits from Frontend / Web traffic
Without edge caching, identical Shopify 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
Create SHOPIFY_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.
Configure upstream steps and output mapping
Use GET against https://{{secrets.SHOPIFY_STORE}}.myshopify.com/products/{{query.handle}}.js. Allowed origins on the client token should match set cache ttl to 300s so repeat gets with the same query string hit caches.default. Storefront product .js endpoints are GET-friendly for edge cache. Admin GraphQL is POST and bypasses this cache layer.
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-shopify-storefront-api', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_cache-sh",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "cache-shopify-storefront-api"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"productId": "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
- 247 B to 39 B (-84%)
curl -X GET "https://realcomposer.com/v1/workspace/cache-shopify-storefront-api" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Can Frontend / Web call Shopify without holding the production key?
Use scoped tokens where the vendor allows them on cache-shopify-storefront-api. Admin keys stay {{secrets.*}} references only.
How do I forward JSON bodies to POST upstreams?
cache-shopify-storefront-api: only GET requests cache (300s on caches.default). Key is workspace slug plus sorted query params, not Authorization.
How do I rotate upstream credentials?
Upstream steps in cache-shopify-storefront-api honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + Shopify Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.