Mathias
Forum Replies Created
-
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI behaviour – ESI block disapear after a while@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' );
}
});Forum: Plugins
In reply to: [LiteSpeed Cache] ESI behaviour – ESI block disapear after a whileHi @qtwrk ,
The ESI block has stopped working. Only the comments are displayed, see below :
Regarding the result for the following URL with the
lsesiparameter :https://www.my-website.com/?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54dWhen putting the URL with
lsesiparameter on the browser, everything works perfectly. The timestamp is correct, and the litespeed_esi_load function is outputed as expected :
And the
lsesi=xxxxxxURI refering to my ESI block, doesn’t appear on the log anymore.
Any idea where the issue could come from?
ThanksForum: Plugins
In reply to: [LiteSpeed Cache] ESI behaviour – ESI block disapear after a whileHi @qtwrk ,
Thx for your help,In the debug Include URI, I have added
lsesiparameter.
I have “Purge All” and then open the debug log panel, from there I can see 2 lines referring to the
lsesiparameter :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=7c4c1cf0393efba2e972b43d7fb6a54d10/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=7c4c1cf0393efba2e972b43d7fb6a54dAnd open in the browser the following URL :
https://www.my-website.com/?lsesi=BW_esi_main_menu&_control=private%2Cno-vary&_hash=7c4c1cf0393efba2e972b43d7fb6a54dAs 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.
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI behaviour – ESI block disapear after a whileHi @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:49Any 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,Forum: Plugins
In reply to: [LiteSpeed Cache] ESI behaviour – ESI block disapear after a whileHi @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:09The 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,