• Resolved MisterHunter

    (@misterhunter)


    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 block’s cache while leaving all others untouched.

    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    I am not exactly sure what or how do you “re-use” it

    could you please share some sample demo code ?

    Best regards,

    Plugin Support Hai Zheng?

    (@hailite)

    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.

    Thread Starter MisterHunter

    (@misterhunter)

    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).

    Thread Starter MisterHunter

    (@misterhunter)

    @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?

    Plugin Support Hai Zheng?

    (@hailite)

    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.

    Plugin Support Hai Zheng?

    (@hailite)

    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.

    Thread Starter MisterHunter

    (@misterhunter)

    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

    Thread Starter MisterHunter

    (@misterhunter)

    Any information? It would be nice to fully utilize Litespeed properly but the documentation is lacking.

    @hailite @qtwrk

    Plugin Support Hai Zheng?

    (@hailite)

    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.

    Thread Starter MisterHunter

    (@misterhunter)

    Can you provide an example of it being used?

    @hailite @qtwrk

    Thread Starter MisterHunter

    (@misterhunter)

    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 @qtwrk

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Clear ESI Block Cache For Certain Blocks’ is closed to new replies.