Shopify Metafield late update after successful response by rest api

I’m updating product metafields in bulk using Shopify rest API, for different products and every product has the same namespace for the metafield.

foreach($products as $product){
   $metafield = [
      'namespace' => 'app_specific_metafield',
      'key' => 'variable_name'
      'value' => 'value'
   ]; 
}

and I update/create the metafield according to Shopify rest metafield API docs. everything is fine, I get 200 for each product’s metafield update.

But when refreshing the product’s metafield, it didn’t show the changes immediately, ( after X number of times it appears ). Idk if there is any time limit to get the updated metafields reflected.

1 Like

I see a similar delay from the time a metafield value is updated to when an active customer session sees the update on a liquid page section that references that metafield. This is independent of the volume of updates. Just making one update, I see a delay.

This produces a poor user experience for the customer who is expecting to see a result of an action, yet the initial section render does not reflect the metafield change.

What is the delay we should place in our code before we call for a section render after a metafield update?

1 Like

Sometimes updating metafields is taking up to 30 seconds, even if you update just one metafield.

The workaround I found was to update any theme in the store even if its unpublished through REST API and then metafields will be updated instantly.

Hi @amadi84 ,

Thanks for the suggestion. Can you give more details on what you mean by “update any theme in the store” when I am updating a metafield related to a product or customer?

Thanks,

John

What I did is creating a dummy file in the snippet folder of the store theme, and then keep updating it whenever metafields were updated, the result was metafields updated immediately. I used shop metafields in this test, but I think product metafields have same behavior

What I do is POST call REST API with timestamp on the url, ex: {shop}.myshopify.com/admin/api/2023-07/metafields.json?nocache={timestamp}. So the changes of metafields can be displayed immediately on liquid.