Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Clear storefront API cache when updating product

Clear storefront API cache when updating product

Fiischer
Shopify Partner
2 0 2

Hello,

 

I'm encountering a caching issue with the Storefront API. Specifically, when a product is updated in the Shopify Admin, the Storefront API continues to serve a cached, outdated version of the product for several seconds. This seems inconsistent, as the Admin API correctly clears the cache upon product updates.

 

For instance, when our Next.js frontend utilizes a Shopify webhook to revalidate a product page cache, it fetches product data from the Storefront API. Unfortunately, this data is often outdated, leading to incorrect page generation for our cache.

 

Could you clarify whether the Storefront API cache is supposed to clear automatically for that product, when a product is updated in the Shopify Admin, and if not, suggest a solution?

Currently we wait to revalidate the product cache after 10 seconds, but it's still inconsistent.

 

Thank you.

Replies 0 (0)