How to exclude the sidebar from ESI?




Wordpress LScache Plugin: How to exclude the sidebar from ESI?

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi all, I want to exclude the full sidebar from ESI. I read the article of WordPress Shortcodes into ESI Blocks , however, I dont find the clue. I know each widget has a ESI setting function, though. Any solutions? Thank you, Hi @createpop, you can find the LiteSpeed Cache section on each Apperance > Widgets > Widget box. Hi Stanley, Thank you for your comment. Yes, I know we can set ESI for each widgets. But, I want to exclude the full global sidebar from the cache and want a hole to be punched for the sidebar, if possible. Thank you for your support! I see, in this situation, you need to modify the themes code and convert the dynamic_sidebar into ESI, please follow this articles instruction. Thank you for your info. But, the instruction is not enough for me unfortunately. I dont know how to insert the code into sidebar.php according to the instruction. Could you share your sidebar.php content with us? (Please put it on gist or pastiebin) We can provide an example for you. Hi, Thank you so much for your support. Gist link for sidebar is below. http://bit.ly/2tEuvnU Thank you! 1) Please replace row 116 & 122 dynamic_sidebar() function into: if ( method_exists( LiteSpeed_Cache_API, hook_tpl_esi ) && LiteSpeed_Cache_API::esi_enabled() ) // This will echo script echo LiteSpeed_Cache_API::esi_url( litespeed_sidebar_esi, Side Bar ESI, array( PUT_SIDEBAR_PARAME_HERE ) ) else // Fall back if ESI not enabled dynamic_sidebar( PUT_SIDEBAR_PARAM_HERE ) (Sidebar param is: $cb_sidebar_id and sidebar-global) 2) Add the following script to your themes function.php if ( method_exists( LiteSpeed_Cache_API, hook_tpl_esi ) && LiteSpeed_Cache_API::esi_enabled() ) // Hook the esi call back script LiteSpeed_Cache_API::hook_tpl_esi(litespeed_sidebar_esi, hook_litespeed_sidebar_esi ) function hook_litespeed_sidebar_esi( $param ) // Print sidebar here with the parameter you put in dynamic_sidebar( $param[ 0 ] ) exit Thank you for your info. Ill try to do it according to your instruction. Unless fitting to my sidebar.php, then Ill let you know. Thank you! Hi, Deleting the code from 116 to 122, then insert the above code? I tried it, but there is an error. Sorry for my lack of knowledge. Id appreciate it if you still support me. Ive commented on your gist with the full code sample, please try on it. For the functions.php code you can keep using the above comments one. Hi Stanley, I tried and tested you code. Everything is fine so far! I have done the function what I want. I really appreciated your support and effort!Thank you so muchYour welcome @createpop. Happy to read you solve your issue.



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



Reference