{
  "slug": "cache-shopify-storefront-api",
  "title": "How to Cache Shopify Storefront API Queries",
  "metaDescription": "How to cache shopify storefront api queries. Shield Shopify with 300s GET edge cache; cache key uses query params on cache-shopify-storefront-api.",
  "headline": "Shopify GET traffic cached ahead of rate limits",
  "category": "caching",
  "categoryLabel": "Edge Caching & Rate Limits",
  "urgency": 8,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "Shopify"
  ],
  "searchIntentQuery": "how to cache shopify storefront api queries",
  "directAnswerSummary": "Shopify rate limits hit fast from Frontend / Web. Cache 300s on GET calls where the query string scopes the response.",
  "problem": {
    "title": "Shopify rate limits from Frontend / Web traffic",
    "explanation": "Without edge caching, identical Shopify 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": "Create SHOPIFY_ACCESS_TOKEN vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "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."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/cache-shopify-storefront-api', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "How to Cache Shopify Storefront API Queries",
    "method": "GET",
    "cacheTtlSeconds": 300,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "shopify",
        "upstreamUrlTemplate": "https://{{secrets.SHOPIFY_STORE}}.myshopify.com/products/{{query.handle}}.js",
        "httpMethod": "GET",
        "headersTemplate": {},
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "productId",
          "sourcePath": "products.0.id",
          "type": "number",
          "sourceStep": "shopify"
        },
        {
          "targetPath": "title",
          "sourcePath": "products.0.title",
          "type": "string",
          "sourceStep": "shopify"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "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"
      }
    }
  },
  "sampleSlimmedOutput": {
    "productId": "sample",
    "title": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/cache-shopify-storefront-api\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Can Frontend / Web call Shopify without holding the production key?",
      "answer": "Use scoped tokens where the vendor allows them on cache-shopify-storefront-api. Admin keys stay {{secrets.*}} references only."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "cache-shopify-storefront-api: only GET requests cache (300s on caches.default). Key is workspace slug plus sorted query params, not Authorization."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Upstream steps in cache-shopify-storefront-api honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "combine-algolia-search-with-user-favorites",
    "edge-caching-reverse-proxy",
    "call-airtable-from-flutterflow-securely"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/cache-shopify-storefront-api",
    "markdown": "https://realcomposer.com/recipes/cache-shopify-storefront-api.md",
    "json": "https://realcomposer.com/recipes/cache-shopify-storefront-api.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=cache-shopify-storefront-api&via=agent"
  }
}