How to purge cache w/APO when using WP Discourse?
-
With we are running the Cloudflare plugin with APO. We are also using the WP Discourse plugin for blog comments. However, once a comment is added to a post, APO does not recognize a comment was added so the cache for that post is not purged. That means the comment count on the WordPress post never updates.
We had a similar issue with WP Rocket not purging the cache when a new comment was added to the forum. I worked with those guys and they provided the following code which works.
if( function_exists( 'rocket_clean_post' ) ){ add_action( 'wpdc_after_webhook_post_update', 'bulk_rocket_clean_post’); } function bulk_rocket_clean_post(array $ids){ foreach ($ids as $id) { rocket_clean_post($id); } }
The
wpdc_after_webhook_post_update
action was provided by the WP Discourse team. The rest of the code came from the WP Rocket team to fire the action.My question, what code can we add to our site so when someone leaves a comment on the forum, it registers with the Cloudflare plugin so the APO cache for that post is purged and the comment count is updated on the WordPress post?
Thank you!!
- The topic ‘How to purge cache w/APO when using WP Discourse?’ is closed to new replies.