• Resolved vavoomshop

    (@vavoomshop)


    Hello,
    We have to purge the cache at least 3 times a day.
    Is there a way to schedule cache purges by time period?
    For example
    04:00 cache purge
    12:00 cache purge
    17:00 cache purge

    Also, cache purge should work only for specific pages.
    https://forexample.com/product/….
    Cache purge should be performed by time slot only for product pages.

    best regards

Viewing 7 replies - 1 through 7 (of 7 total)
  • serpentdriver

    (@serpentdriver)

    Is there a way to schedule cache purges by time period?

    No, you can purge cache only once a day by a specific day time. Your need can be done, but not with plugin functions. This needs a custom solution.

    Thread Starter vavoomshop

    (@vavoomshop)

    Has confirmed.
    Need to add a specific feature as a customization?
    For example

    <?php
    
    // wrap this in a function
    if (class_exists('\LiteSpeed\Purge')) {
      \LiteSpeed\Purge::purge_all();
    }
    
    // another way
    if (class_exists('\LiteSpeed\Purge')) {
      do_action('litespeed_purge_all');
    }
    
    ?>

    Are you saying this?

    best regards

    serpentdriver

    (@serpentdriver)

    That would be a possible solution, but I prefer another solution that is independent of WordPress and the cache plugin, which is also faster.

    Thread Starter vavoomshop

    (@vavoomshop)

    Thank you for answer.
    Do you know of another quick independent solution?
    I do not know.
    best regards

    serpentdriver

    (@serpentdriver)

    Create an empty PHP file with name of your choice, copy the code from below in this file and transfer the file to the root directory of your server where WP is installed. This file can only be run from console (SSH) and you can use it for cron job.

    <?php
    if (php_sapi_name() !== 'cli') {
        exit("\n");
    }
    
    $tag = __DIR__;
    $tag = $tag . '/wp-content/plugins/litespeed-cache/';
    $tag = substr(md5($tag), -3) . '_';
    
    header("X-LiteSpeed-Purge:" . $tag );
    Thread Starter vavoomshop

    (@vavoomshop)

    Thanks for the reply!
    I will give feedback after testing
    best regards

    Plugin Support qtwrk

    (@qtwrk)

    better to use plugin API if possible, e.g.

    <?php 
    require( './wp-load.php' );
    if ( defined('LSCWP_V')) {
      do_action( 'litespeed_purge_url', '/product/something' );
    }

    and curl/wget it , don’t run it in PHP CLI

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cache purging scheduling question’ is closed to new replies.