Does Vue Storefront ensure cache consistency across distributed middleware nodes?
0 reputation · 26 Nov 2020, 16:15 UTC
0 reputation · 26 Nov 2020, 16:15 UTC
Vue Storefront utilizes a middleware layer to decouple the frontend from backend APIs, often implementing caching strategies to minimize latency. In clustered environments where multiple middleware instances are deployed, the system must synchronize cache purges to prevent stale data from being served to users.
While the framework supports the stale-while-revalidate pattern and integrates with backend webhooks for invalidation, there is uncertainty regarding the propagation of these purge events across a distributed architecture. If a webhook triggers a cache clear on a single node, other active nodes may continue serving outdated product prices or stock levels until their respective TTL expires.
32275 reputation · 26 Nov 2020, 22:46 UTC
Vue Storefront (VSF) does not natively provide a built-in synchronization engine to broadcast cache purge events across distributed middleware nodes. Instead, cache consistency is a function of the external caching infrastructure and the storage backend configured within the middleware layer.
In a distributed architecture, if the middleware uses a local in-memory cache, a webhook trigger sent to a single node will only invalidate that specific node's memory. Other nodes will continue to serve stale data until their Time-to-Live (TTL) expires. To achieve global consistency, VSF typically relies on one of two architectural patterns:
To ensure and verify consistency across your cluster, follow these steps:
curl to request the same resource from different node IPs and inspect the X-Cache or Age headers to see if they are hitting a shared cache or independent local caches.Diagnostic Detail Needed: To provide a more specific recommendation, please clarify if your current deployment utilizes a shared Redis instance or relies on local node memory for caching.
Use comments to ask for clarification. Post a solution as an answer.
32,275 reputation · 27 Nov 2020, 00:48 UTC
Vue Storefront does not ship a cross‑node broadcast layer; cache consistency is driven by the store you configure in vue‑storefront.yml. When the cache-store is set to redis, a PURGE or DEL issued by a webhook hits the shared Redis instance, instantly removing the key for every middleware node that reads from it. If you’re using the default in‑memory store, each node keeps its own copy, so a purge on one instance only clears that node’s memory. In that case, you’ll need an external message bus (Kafka, RabbitMQ, or Redis Pub/Sub) to notify all nodes to flush or refresh.
Quick check: run redis-cli against the shared endpoint, list the keys, trigger a purge, and confirm the key disappears from all clients.