Clear ESI Block Cache For Certain Blocks




Wordpress LScache Plugin: Clear ESI Block Cache For Certain Blocks

Last Updated on: Wed, 15 Apr 2026 00:00:02
I have created an ESI block following the Usage Example on this page: https://docs.litespeedtech.com/lscache/lscwp/api/ And I am able to purge the blocks cache using this code: do_action(litespeed_purge_esi, random_esi_block) However I will be re-using this block for multiple items being listed on the page with slightly different parameters, how can I refresh just a single instance of the block based on an ID or parameters? So basically if an action happened on the 3rd block we would just want to purge the 3rd blocks cache while leaving all others untouched. Thanks. Hi, I am not exactly sure what or how do you re-use it could you please share some sample demo code ? Best regards, The ESI tag is the only parameter in the API that can be used to purge. If you would like to purge a custom tag, you can generate a cache tag by litespeed_tag_add API and purge it by litespeed_purge. An example would be for WooCommerce products that are within a loop on the shop page, the same block would be re-used in the loop to display different products but I only want to clear a single instance of the ESI block (e.g. product with ID 68). @hailite So I would be able to add this to a custom ESI block: do_action( litespeed_tag_add, the_new_tag_ . $id ) where $id would be unique to the post. Then if I wanted to only purge the ESI block associated with post ID 68 I would call: do_action( litespeed_purge, the_new_tag_68 ) Which would leave all other ESI blocks untouched? I think so. You can run and check debug log to confirm. Besides, if you have many ESI block on one page, better to also use litespeed_esi_combine to lessen the sub-calls. Otherwise, if each WP request takes 2s to load, you have 1 main request + 10 ESI sub requests, it will be 11 2s=22s for your main request to finish. Also can consider to use the last param $inline_param of function sub_esi_block() when creating ESI URL to bypass the sub request calls when generating the main page by inline the value of that ESI request. Do you have any documentation or examples illustrating how to use litespeed_esi_combine? Also, what exactly does the $inline_param do? There is no description for it on this page that explains it at all from what I can see: https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url Any information? It would be nice to fully utilize Litespeed properly but the documentation is lacking. @hailite @CacheCrawler For that you will need to read the code in https://github.com/litespeedtech/lscache_wp/blob/master/src/esi.cls.php#L406 It will inline the ESI content to avoid 2nd call to that ESI. Can you provide an example of it being used? @hailite @CacheCrawler Are there any plans to document this code? Or can you direct me to somehow who does know how to use this undocumented code? @hailite @CacheCrawler



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference