This is an old revision of the document!

How to Turn Custom Code into an ESI Block

Please note that this requires v3.0 rc 10 or later.

Add the following code into the place where you want to insert the block:

apply_filters( 'litespeed_esi_url', 'my_esi_block', 'Custom ESI block' );

For example :

apply_filters( 'litespeed_esi_url', 'my_esi_block', 'Custom ESI block' );

and then add following code into your theme's functions.php:

add_action( 'litespeed_esi_load-my_esi_block', 'my_esi_block_esi_load' );

function my_esi_block_esi()
do_action( 'litespeed_control_set_ttl', 300 );
echo "Hello world";

In this example, my_esi_block is the block name, Custom ESI block is a 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 12:59
  • by Lisa Clarke