User specific content in ESI block not updated after private cache purge




Wordpress LScache Plugin: User specific content in ESI block not updated after private cache purge

Last Updated on: Wed, 15 Apr 2026 00:00:02
Im trying to have an ESI block that is user specific purged after the user is updated in the back-end. Here is my functions.php code: function show_user_tracks_esi( $from_esi = false ) if ( ! $from_esi ) if( method_exists( LiteSpeed_Cache_API, esi_enabled ) && LiteSpeed_Cache_API::esi_enabled() ) if ( method_exists( LiteSpeed_Cache_API, v ) && LiteSpeed_Cache_API::v( 1.3 ) ) return LiteSpeed_Cache_API::esi_url( user_tracks_esi, BT, array(), private,no-vary ) ob_start() get_template_part( inc/xxx ) return ob_get_clean() if ( method_exists( LiteSpeed_Cache_API, esi_enabled ) && LiteSpeed_Cache_API::esi_enabled() ) LiteSpeed_Cache_API::hook_tpl_esi(user_tracks_esi, hook_user_tracks_esi ) function hook_user_tracks_esi( $params ) $user_id = get_current_user_id() LiteSpeed_Cache_API::add_private( bt_user_ . $user_id ) echo show_user_tracks_esi( true ) exit add_action( profile_update, my_profile_update, 10, 2 ) function my_profile_update( $user_id, $old_user_data ) if ( class_exists(LiteSpeed_Cache_API) ) LiteSpeed_Cache_API::purge_private(bt_user_ . $user_id) Expand Here is the debug info displayed after the ESI block: Im getting this in debub.purge.log, which sugests that the purging is beeing done: ?? ------POST HTTP/1.1 (HTTPS) /wp-admin/user-edit.php Query String: HTTP_REFERER: https://XXX/wp-admin/user-edit.php?user_id=9&wp_http_referer=%2Fwp-admin%2Fusers.php User Agent: Mozilla/5.0 (Windows NT 10.0 Win64 x64 rv:71.0) Gecko/20100101 Firefox/71.0 Accept: text/html,application/xhtml+xml,application/xml q=0.9, / q=0.8 Accept Encoding: gzip, deflate, br Cookie _lscache_vary: admin_bar:1 logged-in:1 role:99 role_exclude_cache:1 X-LSCACHE: true LSCACHE_VARY_COOKIE: cookie_notice_accepted,bt_warning_dismissed X-LiteSpeed-Purge: private,01f_bt_user_9 => LSC->send_headers()@680 => WP_Hook->apply_filters()@288 => WP_Hook->do_action()@312 => /XXX/wp-includes/load.php@478 However, the page is kept with the old stale block, until the user logs out and back in again. Interestingly, even if I do if ( class_exists(LiteSpeed_Cache_API) ) LiteSpeed_Cache_API::purge_private_all() on user update instead of beeing specific, the result is the same. Thank you! Hi @hlsg, purging private cache need to sent by cache owner, so purge_private_all is not worked on system-wise. Please try to use LiteSpeed_Cache_API::tag_add and LiteSpeed_Cache_API::purge( $tag ) to purge the ESI by tag. Excellent! As much as I love your plugin, I must say that you documentation is a bit lacking. Better docs would go a long way towards reducing your workload answering such issues. All that beeing said, thank you very much fot the info!



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



Reference