Client-side post-hydration fetch vs short-TTL edge caching for Vue Storefront mini-cart counters on cacheable catalog pages
0 reputation · 06 Sept 2022, 21:19 UTC
0 reputation · 06 Sept 2022, 21:19 UTC
In Vue Storefront (Alokai), anonymous catalog pages are usually cached in layers: a server-side cache such as Redis for API and SSR aggregation, plus a CDN for anonymous traffic, while cart, checkout, and customer routes are excluded from shared caches. The unresolved point is how to render personalized header fragments—mini-cart counters, wishlist totals, or group pricing—inside an otherwise cacheable page.
There is no single documented default for these fragments. A team must choose between fetching them client-side after hydration so cached HTML stays generic, or accepting a short TTL on the full page and tolerating brief staleness. Each option trades latency and origin load against correctness and complexity.
Cache-key dimensions and route exclusions differ across Vue Storefront and Alokai releases, so the behavior is version-sensitive and should be confirmed against the installed version's documentation and staging behavior.
Which approach better matches documented caching behavior for personalized fragments on cacheable catalog pages: client-side post-hydration fetching, or short-TTL edge caching with server-side invalidation? How should cache keys and route exclusions be scoped so store, currency, locale, and customer-group data never bleed across sessions? At what staleness threshold should a mini-cart counter be treated as private and excluded from shared caches entirely?
33775 reputation · 07 Sept 2022, 02:24 UTC
For personalized fragments such as mini-cart counters, wishlist totals, or group pricing on otherwise cacheable catalog pages, client-side post-hydration fetching is the approach that better matches documented Vue Storefront and Alokai caching behavior. Short-TTL edge caching of full pages that contain private data is generally discouraged because it forces session-aware cache keys or Vary headers that erode CDN hit rates and create leakage risk.
When a mini-cart counter is embedded in cached HTML, the CDN must distinguish every shopper. Adding a session or cart identifier to the cache key turns a shared asset into a per-user object, which defeats the purpose of edge caching and can degrade cache efficiency. Even with a short TTL, the window between cache writes is enough for one anonymous session to receive another session's fragment if key scoping is imperfect. The safer boundary is to keep private data out of shared caches entirely and let the catalog shell remain globally cacheable.
It is well established that anonymous catalog, category, and product pages are intended to be cached at the CDN and server layers, while cart, checkout, and customer routes are excluded from shared caches. It is also a common architectural pattern to hydrate private fragments client-side so the cached HTML stays generic. What is less certain without checking your installed version is how the SSR layer initializes private state: older Vue Storefront releases and newer Alokai middleware differ in whether a server-side aggregation step already attempts to inline cart data, and whether that data is properly stripped before caching. Treat the exact hydration boundary as version-sensitive and verify it in staging.
no-store or bypassed at the CDN and Redis layers.Cache-Control: private, no-store.HIT (e.g., X-Cache: HIT), while the cart API shows BYPASS or MISS.Which Vue Storefront or Alokai version and server middleware are you running? If your release already inlines cart state during SSR and strips it before caching, you may only need to disable that inlining and add a client fetch. If it does not, the wiring effort is higher and the short-TTL temptation is stronger—but still not advisable for shared caches.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.