Updating a cart with storefront API takes 3x the time on certain store

Hi,

I’m running a cartUpdate with the storefront API. Nothing crazy, adding a few products and a metafield to the cart.

Operation times (for same query) varies between 700ms and 2900(!!)ms between stores.

Why could that be?

When using Hydrogen, your requests do not go directly from the browser to Shopify’s Storefront API like a typical headless client. Instead, Hydrogen runs on Cloudflare Workers, so the cart update request first goes to the Cloudflare worker closest to the customer’s location, and only then is forwarded from that edge location to Shopify’s servers. This extra hop can make cart operations appear slower compared to calling the Storefront API directly from a backend that is already close to Shopify’s infrastructure, and the impact can vary between stores depending on where most of their traffic originates geographically.​

However, the perceived speed for shoppers does not have to match the raw API latency. Hydrogen provides useOptimisticCart, which lets you update the cart UI immediately in the browser while the actual cart mutation is still in flight to Shopify. With an optimistic cart implementation, customers see items added or updated instantly, and the UI then reconciles with the server response once it returns, which largely removes the UX impact of those slower requests as long as you handle optimistic states correctly