Invalidate getEntityRecords Cache in the WordPress Block Editor (Gutenberg)

Matt Watson's photo
Matt Watson
·Jul 28, 2022·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

If you have used the Gutenberg API to include post data in your blocks, say with getEntityRecords, and you have some level of interactivity that changes the block, you may find that the block will not update do to the cache.

To clear the cache use this technique: 'core' ).receiveEntityRecords( 'postType', 'post', [], {}, true );

The fifth parameter will ensure the cache is invalidated, and the calls getEntityRecords within your block will be reloaded.

Share this