Skip to content

perf(storefront/api): add cacheTag/cacheLife to brand, vendor, blog, article, header, footer, infobar APIs #1985

Description

@filiphsps

What to build

Several Shopify data fetchers run inside 'use cache' boundaries but emit no cacheTag / cacheLife. Their callers cache by content hash and rely solely on cacheLife('max') for expiry. Webhook-driven invalidation cannot reach them — when a shop admin edits a vendor, the cached storefront copy persists until the cache simply ages out.

Sites missing tags:

  • apps/storefront/src/api/shopify/brand.ts:64-65api.query(BRAND_QUERY) has no tags
  • apps/storefront/src/api/shopify/vendor.ts:62-63api.query(VENDORS_QUERY) has no tags
  • apps/storefront/src/api/_loaders.ts:52-57BlogApi, ArticleApi, HeaderApi, FooterApi, InfoBarApi use react.cache() only; the safeCacheTag pattern that ProductApi (line 38) and CollectionApi (line 45) use is missing

Reference shape: apps/storefront/src/api/shopify/search.ts:110-123 (cacheLife('hours') + cacheTag(...) with shop+locale keys).

Acceptance criteria

  • Every listed API attaches cacheTag keyed by shop + locale (and entity id where applicable)
  • Every listed API attaches a reasonable cacheLife (e.g. 'hours' for content, 'max' for static-ish data)
  • Tests added/updated to assert cacheTagMock is called with the expected tags — mirror the pattern in search.test.ts
  • Webhook handler in the revalidation route can target each of these by tag (verify by following the chain from revalidate/route.ts)

Blocked by

None — can start immediately.

References

  • apps/storefront/src/api/shopify/brand.ts:64
  • apps/storefront/src/api/shopify/vendor.ts:62
  • apps/storefront/src/api/_loaders.ts:52
  • apps/storefront/src/api/shopify/search.ts:110 — reference impl
  • apps/storefront/src/app/[domain]/api/revalidate/

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIOptimizationPerformance or bundle optimizations.ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions