xcladeDocs
Storefront GraphQL

Performance & Caching

Go DataLoader SQL batching, XcladeResponseCache Redis allowlist & TTLs, APQ, and Typesense Instant Search

Performance & Caching

xclade achieves sub-50ms storefront response times by combining compiled Go execution, per-request DataLoader SQL batching, Redis response caching, and Automatic Persisted Queries.


1. Go DataLoader SQL Batching

Every GraphQL request hydrates a fresh set of per-request Go DataLoaders (graph/loaders/), collapsing nested resolver reads into single WHERE id = ANY($1) PostgreSQL queries for:

  • Collections (ListCollectionsByIDs)
  • Product Types (ListProductTypesByIDs)
  • Currencies (ListCurrenciesByCodes)
  • Regions & Countries (ListRegionsByIDs, ListCountriesByRegionIDs)
  • Order Line Items (ListItemsByOrderIDs)

2. XcladeResponseCache (Redis-Backed Allowlist)

The Go ResponseCacheExtension (graph/middleware/caching.go) caches strictly public, anonymous, read-only Storefront queries in Redis. Every cache key hashes:

SHA-256( tenantScope | sorted(salesChannelIDs) | locale | operationName | rawQuery | variables )

Allowlisted Public Root Queries & TTLs

Root Query FieldRedis TTL
locales, currency, currencies60 minutes
region, regions30 minutes
brand, brands5 minutes
product, productByHandle, products1 minute
collection, collectionByHandle, collections1 minute
productCategory, productCategoryByHandle, productCategories1 minute
siteSettings1 minute

When a single query selects multiple allowlisted root fields, the cache uses the shortest TTL among them. Any query containing a non-allowlisted root field (such as cart, orders, authStatus, myCompany, or quotes)—or any authenticated request or sensitive ID (cart_id, company_id, customer_id)—bypasses the cache completely and returns Cache-Control: private, no-store.

Cache Headers & Automatic Invalidation

  • Cache Hit: Returns X-Cache: HIT and Cache-Control: public, max-age=60, stale-while-revalidate=300.
  • Cache Miss: Executes against Postgres, populates Redis under tag gql:public, and returns X-Cache: MISS.
  • Automatic Invalidation: Any successful mutation automatically invalidates the gql:public tag so catalog or CMS changes appear immediately.

3. Automatic Persisted Queries (APQ) & AST Cache

  • Parsed AST LRU Cache: Up to 1,000 parsed GraphQL documents stay hot in memory per store pod.
  • APQ Hash Cache: Clients supporting Apollo/urql APQ can send only the SHA-256 hash (extensions.persistedQuery) over GET /graphql (512-entry LRU cache), shrinking request payloads and enabling CDN edge caching on public catalog reads.

For typo-tolerant faceted catalog search at scale, stores automatically index published products into Typesense. Trigger a full reindex at any time via Merchant Admin GraphQL:

mutation ReindexCatalog {
  reindexSearch
}

On this page