Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:cache:lscwp:esi_block [2020/04/02 20:58]
qtwrk created
litespeed_wiki:cache:lscwp:esi_block [2020/04/03 12:59]
Lisa Clarke Copy editing
Line 1: Line 1:
-Please note that this will requires v3.0 rc 10 and later.+====== How to Turn Custom Code into an ESI Block ======= 
 +**Please note that this requires v3.0 rc 10 or later.**
  
-===== How to make my code into ESI block ====== +Add the following ​code into the place where you want to insert the block:
- +
-add following code +
  
 ''​apply_filters( '​litespeed_esi_url',​ '​my_esi_block',​ '​Custom ESI block' ); ''​ ''​apply_filters( '​litespeed_esi_url',​ '​my_esi_block',​ '​Custom ESI block' ); ''​
  
-to where you want to insert the block, ​ for example :+For example :
  
 <​code>​ <​code>​
Line 17: Line 16:
 </​code>​ </​code>​
  
-and then add following code into your theme'​s ​**functions.php**:+and then add following code into your theme'​s ​''​functions.php''​:
  
 <​code>​ <​code>​
Line 24: Line 23:
 function my_esi_block_esi() function my_esi_block_esi()
 { {
 +do_action( '​litespeed_control_set_ttl',​ 300 );
 echo "Hello world";​ echo "Hello world";​
 } }
 </​code>​ </​code>​
  
-where **my_esi_block** is the block name , for your convenience ,  **Custom ESI block** is short comment+In this example, ''​my_esi_block'' ​is the block name, ''​Custom ESI block'' ​is short comment, and ''​300''​ is the TTL for this block. 
 + 
 +You can change it to ''​do_action( '​litespeed_control_set_nocache'​ );''​ or change ''​300''​ to ''​0''​ , if you want to set this block to ''​no-cache''​.
  • Admin
  • Last modified: 2020/04/03 21:01
  • by qtwrk