Stale ESI block after apparently sucessful private cache purge
-
I’m trying to have an ESI block that is user specific purged after the user is updated.
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); }
Here is the debug info displayed after the ESI block:
<!-- Block generated by LiteSpeed Cache 2.9.9.2 on 2019-12-17 00:52:02 --> <!-- X-LiteSpeed-Cache-Control: private,no-vary,max-age=1800 --> <!-- X-LiteSpeed-Tag: 01f_tag_priv,01f_bt_user_8,public:01f_ESI,public:01f_ESI.user_tracks_esi,public:01f_ -->
I’m getting this in
debub.purge.log
, which sugests that the purging is beeing done:e?’“ ------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!
- The topic ‘Stale ESI block after apparently sucessful private cache purge’ is closed to new replies.