• Resolved mohammadnrhi

    (@mohammadnrhi)


    Hello, I cache my WooCommerce product page, I call a function on the product page, I want to set this function as an exception so that it is not cached, but the rest of the product page is.
    How should I do this?

    My functions:

    az_product_price_woo( get_the_ID() );
    az_add_product_woo( get_the_ID() );

Viewing 2 replies - 16 through 17 (of 17 total)
  • Thread Starter mohammadnrhi

    (@mohammadnrhi)

    Oh, I get it now, so a function can be ESI and the initial code doesn’t necessarily need to be ESI

    Can you tell me how to ESI another part of that page? I need to add two “add_action” to the function?

    example for first block:

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

    and add this to function.php:

    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' );
    az_product_price_woo( get_the_ID() );
    az_add_product_woo( get_the_ID() );
    }

    then for second block:

    echo apply_filters( 'litespeed_esi_url', 'my_esi_block_second', 'Custom ESI block' );

    and add this to function.php:

    add_action( 'litespeed_esi_load-my_esi_block_second', 'my_esi_block_second_esi_load' );
    
    function my_esi_block_second_esi_load()
    {
    do_action( 'litespeed_control_set_nocache' );
    my code
    }

    Its true? Can’t it be optimized? To have only one add_action for example?

    Plugin Support qtwrk

    (@qtwrk)

    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' );
        // your code for block 1
    }
    
    
    add_action( 'litespeed_esi_load-my_esi_block2', 'my_esi_block2_esi_load' );
    function my_esi_block2_esi_load()
    {
        do_action( 'litespeed_control_set_nocache' );
        // your code for block 2
    }
    
    
      apply_filters( 'litespeed_esi_url', 'my_esi_block', 'Custom ESI block 1' );
      // where you put block 1 output
      apply_filters( 'litespeed_esi_url', 'my_esi_block2', 'Custom ESI block 2' );
      // where you put block 2 output

    something like that

Viewing 2 replies - 16 through 17 (of 17 total)

The topic ‘Exception function’ is closed to new replies.