Title: Exception function
Last modified: November 28, 2023

---

# Exception function

 *  Resolved [mohammadnrhi](https://wordpress.org/support/users/mohammadnrhi/)
 * (@mohammadnrhi)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exception-function/)
 * 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)

[←](https://wordpress.org/support/topic/exception-function/?output_format=md) [1](https://wordpress.org/support/topic/exception-function/?output_format=md)
2

 *  Thread Starter [mohammadnrhi](https://wordpress.org/support/users/mohammadnrhi/)
 * (@mohammadnrhi)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exception-function/page/2/#post-17247118)
 * 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:
 *     ```wp-block-code
       echo apply_filters( 'litespeed_esi_url', 'my_esi_block', 'Custom ESI block' );
       ```
   
 * and add this to function.php:
 *     ```wp-block-code
       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:
 *     ```wp-block-code
       echo apply_filters( 'litespeed_esi_url', 'my_esi_block_second', 'Custom ESI block' );
       ```
   
 * and add this to function.php:
 *     ```wp-block-code
       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](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/exception-function/page/2/#post-17248079)
 *     ```wp-block-code
       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)

[←](https://wordpress.org/support/topic/exception-function/?output_format=md) [1](https://wordpress.org/support/topic/exception-function/?output_format=md)
2

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

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 17 replies
 * 2 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/exception-function/page/2/#post-17248079)
 * Status: resolved