Invalidate getEntityRecords Cache in the WordPress Block Editor (Gutenberg)


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.