ndiego / block-visibility

Conditional visibility controls for all WordPress blocks.
https://www.blockvisibilitywp.com
GNU General Public License v2.0
130 stars 10 forks source link

Add an extensibility mechanism for caching plugins #104

Open ndiego opened 5 months ago

ndiego commented 5 months ago

Block Visibility currently does not have a mechanism for clearing a page's cache when a block needs to become visible, such as with the Date & Time control. The general advice is to disable caching on pages that require dynamic content. Is there an extensibility mechanism that could be added to the plugin that would make it much easier for developers to use third-party caching plugins alongside Block Visibility?

Feedback from WP Rocket:

For the cache to be cleared automatically, the block would need to trigger an update of the post itself. So to make this work, maybe you could check with the plugin developer to see if there is any action that is fired when the block is supposed to become visible. Then you could write a small function that hooks into it to clear the cache for that post, using rocket_clean_post().

MadtownLems commented 1 month ago

Came here looking for guidance on breaking cache stuff. The idea of updating the post when a schedule changes is a cool approach that would cover a lot of those date/time ones, but wouldn't necessary help some of the other conditionals.

I'd also love to see a helper function such as "post_uses_block_visibility()" so that people could use to check if a post uses block visibility, and if so, disable page caching for it completely (similar to what we do for pages with Gravity Forms on them)