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 Field | Redis TTL |
|---|---|
locales, currency, currencies | 60 minutes |
region, regions | 30 minutes |
brand, brands | 5 minutes |
product, productByHandle, products | 1 minute |
collection, collectionByHandle, collections | 1 minute |
productCategory, productCategoryByHandle, productCategories | 1 minute |
siteSettings | 1 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: HITandCache-Control: public, max-age=60, stale-while-revalidate=300. - Cache Miss: Executes against Postgres, populates Redis under tag
gql:public, and returnsX-Cache: MISS. - Automatic Invalidation: Any successful mutation automatically invalidates the
gql:publictag so catalog or CMS changes appear immediately.
3. Automatic Persisted Queries (APQ) & AST Cache
- Parsed AST LRU Cache: Up to
1,000parsed 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) overGET /graphql(512-entry LRU cache), shrinking request payloads and enabling CDN edge caching on public catalog reads.
4. Typesense Instant Search
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
}