• Resolved hcarsten

    (@hcarsten)


    we are using ESI-caching to cache prices. Currently we are running ls-cache plugin with v 7.5.0.1
    within the esi block execution we are tagging the price snippet with the tag “tag_price”.

    Then we have a function in the WP backend which basically uses :
    do_action('litespeed_purge', 'tag_price');

    This works as is should !

    The price updates are done with a wp-cli command we built. Here after the new prices are loaded we also call do_action('litespeed_purge', 'tag_price'); but here (within the wp-cli) the purge fails. We had this working a while a ago ! I checked the source code and I found this code in the purge-class (line 519 in the _add method):

    if (defined('LITESPEED_CLI')) {
    // Can't send, already has output, need to save and wait for next run
    self::update_option($purge2 ? self::DB_QUEUE2 : self::DB_QUEUE, $curr_built);
    self::debug('CLI request, queue stored: ' . $curr_built);
    } else {
    ...
    }

    So if LITESPEED_CLI the purge seems to be queued. So how can I now really commit the (queued) purge – operations ?

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

Viewing 1 replies (of 1 total)
  • Plugin Support qtwrk

    (@qtwrk)

    the cache is handled by webserver , when you operate at CLI, there is no http request send over/through the webserver, therefore, webserver wouldn’t know the purging action.

    therefore it will be queued and wait for next time the PHP is triggered via http request

    by understanding the nature of cache system, then you will see, then you have 2 options

    1. fire a http request that trigger php , like random query string attached to main URL , or even wp-cron.php , after your WP CLI that inovkes webserver , then the queued request will be fired
    2. workaround by http page , e.g. create a php file with name like my-purge.php , with code
    <?php
    require('/path/to/your/wp-load.php'); # ---> to load wordpress env
    do_action('litespeed_purge', 'tag_price');

    then curl it to purge , like curl https://domain.com/my-purge.php to call the purge.

Viewing 1 replies (of 1 total)

The topic ‘litespeed_purge is not working with wp-cli command’ is closed to new replies.