Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Mathias

    (@mathd)

    @qtwrk ,

    Ok , I will create a ticket to the support.

    I’m using the plugin Permalink Manager Pro, to manage URL and WordPress Permalinks, if it’s can help ?

    In the meantime, until the issue is resolved :
    . How can I set up an “Purge All” function and schedule it to happen once a day?
    . What is the best method to do this ?

    I created a custom plugin, but this do not log anything on the “LiteSpeed Cache Toolbox > Purge Log“, is it normal ? However my custom log implemented with file_put_contents() works fine …
    Thx

    <?php

    /**
    * Plugin Name: BW LSCWP Cron
    * Description: Purge All Cache from Lite Speed Cache plugin, once a day.
    * Version: 1.0.0
    * Text Domain: bw-lscwp-cron
    *
    * @package bw_lscwp-cron
    * @version 1.0.1
    */


    /// "Purge All" Cache function

    function bw_run_cron() {

    if ( defined('LSCWP_V')) {

    // LSCWP Purge All
    do_action( 'litespeed_purge_all' );

    // add logs
    $date = date("Y-m-d H:i:s");
    $file = get_home_path()."BW_logs.txt";
    $content = "\n Purge : litespeed_purge_all ".$date;
    file_put_contents( $file, $content, FILE_APPEND);
    // end logs

    }
    }

    /// Clear Cron when plugin is deactivated

    function bw_clear_cron() {
    wp_clear_scheduled_hook( 'bw_cron' );
    }

    /// Create custom bw_cron action , and init schedule event

    add_action('init', function() {

    add_action( 'bw_cron', 'bw_run_cron' );

    register_deactivation_hook( __FILE__, 'bw_clear_cron' );

    if (! wp_next_scheduled ( 'bw_cron' )) {
    wp_schedule_event( time(), 'daily', 'bw_cron' );
    }
    });
    Thread Starter Mathias

    (@mathd)

    Hi @qtwrk ,

    The ESI block has stopped working. Only the comments are displayed, see below :

    Regarding the result for the following URL with the lsesi parameter :

    https://www.my-website.com/?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d

    When putting the URL with lsesi parameter on the browser, everything works perfectly. The timestamp is correct, and the litespeed_esi_load function is outputed as expected :

    And the lsesi=xxxxxx URI refering to my ESI block, doesn’t appear on the log anymore.

    Any idea where the issue could come from?
    Thanks

    Thread Starter Mathias

    (@mathd)

    Hi @qtwrk ,

    Thx for your help,

    In the debug Include URI, I have added lsesi parameter.

    I have “Purge All” and then open the debug log panel, from there I can see 2 lines referring to the lsesi parameter :

    10/01/24 11:45:07.638 [102.17.117.124:10830 1 S5k] Query String: lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d
    10/01/24 11:45:07.796 [102.17.117.124:10830 1 S5k] ⏺ overwrite REQUEST_URI to ESI_REFERER [from] /?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d [to] /

    I have extracted the following URI from the log:

    ?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d

    And open in the browser the following URL :

    https://www.my-website.com/?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d

    As the ESI currently working for now, the litespeed_esi_load function it’s correctly output.
    We can see that the menu is display as expected :

    I will wait until the ESI stops working, then open that same URL and let you know the result.

    Thread Starter Mathias

    (@mathd)

    Hi @qtwrk ,

    Today on the 2024-10-01 the ESI Blocks have stopped their normal behaviour and do not work.

    See the screenshot below, only the comment are outputted. The timestamp of the ESI block is at 2024-09-30 20:44:57

    On the BW_logs.txt generated by the file_put_contents() function inside the litespeed_esi_load function. Nothing have be outputted.

    Here are the few last line of the Logs, the last output was on the 2024-09-30 19:14:49

     Log : BW_esi_main_menu menu_id=631 2024-09-30 11:52:54
    Log : BW_esi_main_menu menu_id=631 2024-09-30 11:52:55
    Log : BW_esi_main_menu menu_id=631 2024-09-30 11:53:21
    Log : BW_esi_main_menu menu_id=631 2024-09-30 11:53:21
    Log : BW_esi_main_menu menu_id=631 2024-09-30 12:25:15
    Log : BW_esi_main_menu menu_id=631 2024-09-30 12:25:15
    Log : BW_esi_main_menu menu_id=631 2024-09-30 13:15:53
    Log : BW_esi_main_menu menu_id=631 2024-09-30 13:15:53
    Log : BW_esi_main_menu menu_id=1632 2024-09-30 19:14:48
    Log : BW_esi_main_menu menu_id=1632 2024-09-30 19:14:49

    Any idea what could cause the ESI block to be unfunctional ?

    Do you need more info about the LSCP config or website config ? I just activated the LiteSpeed Cache Logs on the toolbox plugin to see if i can get more info…

    Am I the only one experiencing this issue ? As a similar issue was found on the forum an marked as resolved (@wilderlandscody).
    Similar issue : https://wordpress.org/support/topic/strange-esi-behaviour-esi-returning-empty-string-and-forcing-caching-policy/

    Thx,

    Thread Starter Mathias

    (@mathd)

    Hi @qtwrk
    Thx for your answer !

    A file_put_contents() have been added to the function, see code below :


    // Litespeed : Load main-menu without caching for "BW_esi_main_menu" block.
    // Create ESI loader for litespeed cache plugin.
    // Ressource : https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url
    function BW_litespeed_esi_load(){

    do_action( 'litespeed_control_set_nocache' );

    $menu_id = BW_conditional_menu();
    $date = date("Y-m-d H:i:s");

    // add logs
    $file = get_home_path()."BW_logs.txt";
    $content = "\n Log : BW_esi_main_menu menu_id=".$menu_id." ".$date;
    file_put_contents( $file, $content, FILE_APPEND);
    // end logs

    echo '<!-- function BW_litespeed_esi_load() $menu_id = '. $menu_id .' '.$date.'-->';

    wp_nav_menu( array(
    'menu' => $menu_id,
    'container' => false,
    'theme_location' => 'main-menu',
    'menu_class' => 'menu',
    'fallback_cb' => 'penci_menu_fallback',
    ) );

    }

    add_action( 'litespeed_esi_load-BW_esi_main_menu', 'BW_litespeed_esi_load' );

    When ESI works, it’s output correctly a file , see as below the output of BW_logs.txt :



    Log : BW_esi_main_menu menu_id=627 2024-09-29 14:34:11
    Log : BW_esi_main_menu menu_id=627 2024-09-29 14:34:12
    Log : BW_esi_main_menu menu_id=627 2024-09-29 14:34:12
    Log : BW_esi_main_menu menu_id=627 2024-09-29 14:34:13
    Log : BW_esi_main_menu menu_id=632 2024-09-29 14:34:40
    Log : BW_esi_main_menu menu_id=632 2024-09-29 14:34:41
    Log : BW_esi_main_menu menu_id=632 2024-09-29 14:34:54
    Log : BW_esi_main_menu menu_id=632 2024-09-29 14:34:55
    Log : BW_esi_main_menu menu_id=631 2024-09-29 14:35:08
    Log : BW_esi_main_menu menu_id=631 2024-09-29 14:35:09

    The output show that the function is executed 2 times each time the page load as the Main menu is display 2 times on the website (one time on the Header one time on the footer). Is this could be an issue to call twice the litespeed_esi_url filter for the same ESI block on the same page ?

    apply_filters( 'litespeed_esi_url', 'BW_esi_main_menu', 'Show main-menu no cached by Litespeed cache plugin' );


    Otherwise, I will wait for the ESI to stop working and see if anything is outpuded on the BW_logs.txt file, and will let you know
    Cheers,

Viewing 5 replies - 1 through 5 (of 5 total)