• Resolved EdKrasnov

    (@alshoker)


    Hello, dear developers!
    I am faced with such a problem. When users add a comment or vote for a comment, the cache of all articles is cleared. I have a news site and the speed of access to articles and news is important. It becomes expensive to re-cache at least 200 recent articles and news 100 times a day.

    Because of this, many users encounter pages that have not yet been added to the new cache and the page loading speed increases to 5-7 seconds. Clearing the entire cache after posting a news item or adding a comment and voting for a comment seems pointless to me.

    I will be glad if you can tell me:
    1. How can I make sure that after posting a comment and voting for a comment, the cache is cleared only in this particular news, and not throughout the site? Or in general, how do I remove the comment block from the page caching?

    2. How do I not reset the entire cache when adding a new article? On the “Cache” > “Cleanup” page, only “Home page” and “Archives” have been added to the cleanup rules https://skr.sh/sS0vJfOxRiB , but when adding an article, the cache with all articles is cleared anyway.

    3. I use the wpDiscuz 7 comment plugin, they have a function to “Hide the comment text” https://prnt.sc/g2u8Ld-z-UWf The text of the comments appears on the page and in the page code only after clicking on the “View comments” button. But even with this feature enabled, after posting one comment, the cache is cleared for all site pages. Is this logical?

    I ask for help on these three points from both developers and experienced users of the LSCache plugin.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support qtwrk

    (@qtwrk)

    it’s hardcoded into code , not configurable

    I will see if I can work out some magic code snippet on this behavior

    Plugin Support qtwrk

    (@qtwrk)

    okay , I see, the purge was called by wpdiscuz 7 plugin at /wp-content/plugins/wpdiscuz/utils/class.WpdiscuzHelperOptimization.php at line 269 with do_action( "litespeed_purge_post", $postId );

    this call by default will purge the post and all its related pages in which some page you may think to be unnecessary

    please try this :

    edit your theme’s functions.php ,

    put code


    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'wpdAddComment') {
    if (class_exists('LiteSpeed\API')) {
    remove_action('litespeed_purge_post', array(LiteSpeed\API::get_instance(), 'purge_post'));
    add_action('litespeed_purge_post', function($post_id) {
    @header("X-LiteSpeed-Purge: " . LSWCP_TAG_PREFIX . "_Po." . $post_id);
    });
    }
    }

    this should , suppress the default purge behavior when wpdiscuz 7 addming comment to the post itself only , replace that header line to @header("X-LiteSpeed-Purge: nothing"); if you want to completely suppress the purge action on this action.

    Thread Starter EdKrasnov

    (@alshoker)

    Thank you, I will check it and I will definitely give you feedback.
    Please don’t close the topic yet.

    Plugin Support qtwrk

    (@qtwrk)

    thanks, please keep me posted.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.