Title: Mathias's Replies | WordPress.org

---

# Mathias

  [  ](https://wordpress.org/support/users/mathd/)

 *   [Profile](https://wordpress.org/support/users/mathd/)
 *   [Topics Started](https://wordpress.org/support/users/mathd/topics/)
 *   [Replies Created](https://wordpress.org/support/users/mathd/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/mathd/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/mathd/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/mathd/engagements/)
 *   [Favorites](https://wordpress.org/support/users/mathd/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LiteSpeed Cache] ESI behaviour – ESI block disapear after a while](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/)
 *  Thread Starter [Mathias](https://wordpress.org/support/users/mathd/)
 * (@mathd)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/#post-18051030)
 * [@qtwrk](https://wordpress.org/support/users/qtwrk/) ,
   Ok , I will create a ticket
   to the support.I’m using the plugin [Permalink Manager Pro](https://permalinkmanager.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
 *     ```wp-block-code
       <?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 functionfunction 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 deactivatedfunction bw_clear_cron() {    wp_clear_scheduled_hook( 'bw_cron' );}/// Create custom bw_cron action , and init schedule eventadd_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' );    }});
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LiteSpeed Cache] ESI behaviour – ESI block disapear after a while](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/)
 *  Thread Starter [Mathias](https://wordpress.org/support/users/mathd/)
 * (@mathd)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/#post-18047852)
 * Hi [@qtwrk](https://wordpress.org/support/users/qtwrk/) ,
   The ESI block has stopped
   working. Only the comments are displayed, see below :
 * ![](https://i0.wp.com/i.imgur.com/WzMxu6A.png?ssl=1)
 * Regarding the result for the following URL with the `lsesi` parameter :
 *     ```wp-block-code
       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 :
 * ![](https://i0.wp.com/i.imgur.com/ANYoLtj.png?ssl=1)
 * 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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LiteSpeed Cache] ESI behaviour – ESI block disapear after a while](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/)
 *  Thread Starter [Mathias](https://wordpress.org/support/users/mathd/)
 * (@mathd)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/#post-18047300)
 * Hi [@qtwrk](https://wordpress.org/support/users/qtwrk/) ,
   Thx for your help,
 * In the **debug Include URI**, I have added `lsesi` parameter.
 * ![](https://i0.wp.com/i.imgur.com/M5OX7rE.png?ssl=1)
 * I have “**Purge All**” and then open the **debug log panel**, from there I can
   see 2 lines referring to the `lsesi` parameter :
 *     ```wp-block-code
       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
       ```
   
 *     ```wp-block-code
       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:
 *     ```wp-block-code
       ?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54d
       ```
   
 * And open in the browser the following URL :
 *     ```wp-block-code
       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 :
 * ![](https://i0.wp.com/i.imgur.com/539Fsd6.png?ssl=1)
 * I will wait until the ESI stops working, then open that same URL and let you 
   know the result.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LiteSpeed Cache] ESI behaviour – ESI block disapear after a while](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/)
 *  Thread Starter [Mathias](https://wordpress.org/support/users/mathd/)
 * (@mathd)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/#post-18046552)
 * Hi [@qtwrk](https://wordpress.org/support/users/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**
 * ![](https://i0.wp.com/i.imgur.com/tGvQPLf.png?ssl=1)
 * 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**
 *     ```wp-block-code
        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/](https://wordpress.org/support/topic/strange-esi-behaviour-esi-returning-empty-string-and-forcing-caching-policy/)
   Thx,
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[LiteSpeed Cache] ESI behaviour – ESI block disapear after a while](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/)
 *  Thread Starter [Mathias](https://wordpress.org/support/users/mathd/)
 * (@mathd)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/esi-behaviour-esi-block-disapear-after-a-while/#post-18043501)
 * Hi [@qtwrk](https://wordpress.org/support/users/qtwrk/) 
   Thx for your answer !
 * A **file_put_contents() **have been added to the function, see code below :
 *     ```wp-block-code
       // 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-urlfunction 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** :
 *     ```wp-block-code
         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 ?
 *     ```wp-block-code
       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 knowCheers,

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