• I noticed on a site with normal WordPress comments enabled that the cache invalidation does not seem to be triggered when a new comment is posted. Could this be corrected somehow?

Viewing 1 replies (of 1 total)
  • Plugin Author Mustafa Uysal

    (@m_uysl)

    Hi @khromov,

    Yes, that’s correct. Inserting a comment doesn’t purge the cache by default. The comment status needs to change for trigger cache invalidation works. (eg: approving)

    However, Powered Cache sets a cookie for commented post powered_cache_commented_posts[' . $post_id . '] that way, the page will be served without caching for the user who made a comment.

    If you still need to purge the cache, you can give it a try this:

    add_action( 'wp_insert_comment', function ( $id ) {
    	$comment  = get_comment( $id );
    	$post_id  = $comment->comment_post_ID;
    	$post_url = get_permalink( $post_id );
    	\PoweredCache\Utils\delete_page_cache( $post_url );
    } );

    It might not be a good decision to leave a cache invalidation to external factors, tho.

    Regards,
    Mustafa

Viewing 1 replies (of 1 total)
  • The topic ‘Doesn’t clear cache when a new comment is posted?’ is closed to new replies.