Disable Caching Specific .PHP File
-
Hello. I have a PHP file named time.php which gives me the current time. The issue is the time remains the same all the time. It only changes when I clear the cache but doesn’t change to the correct time when I reload the page. I’ve done multiple search but no solution yet.
-
you may need to convert it to ESI block
please check this page
Hello. I went through that page but I’m confused. It seems complicated.
Here is my code below:
date_default_timezone_set(‘Africa/Lagos’);
$date = date(‘M d, Y, H:i’);
echo $date.’ WAT.’;Please help.
-
This reply was modified 3 years ago by
electriztown.
in example , you can just replace the part
echo "Hello world".rand (1,99999);to your code
Hello, there are other random stuffs in the codes on the page you shared with me. Should I leave them the same?
Maybe you can give me the code to use with my code. Please…
you can remove the other stuffs in it
I’ve tried but still not working. Perhaps you can please modify the code for me with my code.
Here’s my code:
date_default_timezone_set(‘Africa/Lagos’); echo date(‘M d, Y, H:i’).’ WAT.’;
Please…
Main code.php
$my_var = “test var”;
$my_var2 = “test var 2”;
add_action( ‘litespeed_esi_load-my_esi_block’, function() use ($my_var, $my_var2) {
do_action( ‘litespeed_control_set_nocache’ );
echo “Hello world”.rand (1,99999);
echo ‘
my var:’ . $my_var . $my_var2;
});Functions.php
add_action( ‘litespeed_esi_load-my_esi_block’, ‘my_esi_block_esi_load’);
function my_esi_block_esi_load($params)
{
do_action( ‘litespeed_control_set_nocache’ );
echo “Hello world”.rand (1,99999);
echo var_dump($params);
}Please see what I’m talking about.
add_action( 'litespeed_esi_load-my_esi_block', 'my_esi_block_esi_load' ); function my_esi_block_esi_load() { do_action( 'litespeed_control_set_nocache' ); date_default_timezone_set('Africa/Lagos'); $date = date('M d, Y, H:i'); echo $date. ' WAT.'; }and
echo apply_filters( 'litespeed_esi_url', 'my_esi_block', 'Custom ESI block' );where you want to display it
Thank you for your efforts.
Did you test this to see if it’ll work? It messed up my page and it’s not working at all from my end.
yes , it works on my test , did you enable ESI ? and are you using LiteSpeed Enterprise ?
please provide the report number , you can get it in toolbox -> report -> click “send to LiteSpeed”
and by mess up , how exactly ? any more specific symptom and behavior ?
Thank you for pointing out enabling ESI. I just did now and it’s working fine.
What if I want to have multiple ESI blocks for different items? Please how do I go about it?
Lastly, please I have one more issue. My comment reply doesn’t work. For example, when someone clicks on REPLY in a comment, the reply form doesn’t show up. This issue started as a result of caching. Please help…
Update: My theme doesn’t work properly when ESI is enabled; I can’t edit my pages and post and cannot navigate the theme. I use Pro by Theme.co
How can I upload screenshot here so you can see.
for comment , if you use default setting, does it work ?
and how exactly you can not edit page/post ? it should not affect things in wp-admin area.
I mean, Cornerstone which is Themeco’s Page Builder doesn’t work when ESI is enabled. I searched on this support and found out that someone had similar complain over a year and half ago but he doesn’t seem to have found any solution yet. I’d appreciate if you can get a solution to solve this issue.
Please what do you mean by default settings for the comments?
what exactly is the issue with cornerstone ?
by default I meant if you use default setting , without enable any option , how does comment do ?
-
This reply was modified 3 years ago by
The topic ‘Disable Caching Specific .PHP File’ is closed to new replies.