Wordpress LScache Plugin: Purge caches for specific pages of buddypress.
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hello and thank you for this great cache plugin On my website i am using lightspeed along with buddypress and i have the main members loop page https://www.mysite.com/members/ along with some dynamic subpages https://www.mysite.com/members/joendoe/ https://www.mysite.com/members/joendoe/submissions/ https://www.mysite.com/members/joendoe/shows/ for each user. I am trying to make use of the API with litespeed_purge_url and purge the cache of those specific pages hooking into some actions (and avoid just excluding from page cache the /member/ directory) that only roles above subscriber will do. What i have made: add_action( xprofile_updated_profile, lscwp_purge, 0, 1) add_action( bp_featured_members_user_added, lscwp_purge ) add_action( bp_featured_members_user_removed, lscwp_purge ) function lscwp_purge( $user_id ) if (defined( LSCWP_V ) && ! current_user_can( subscriber ) ) do_action( litespeed_purge_url, https://www.mysite.com/members/ ) do_action(litespeed_purge_url, bp_core_get_user_domain( $user_id ). profile/ do_action(litespeed_purge_url, set_url_scheme( bp_core_get_user_domain( $user_id ). shows/ ) do_action(litespeed_purge_url, set_url_scheme( bp_core_get_user_domain( $user_id ). submissions/ ) but unfortunately i am getting errors with the dynamic urls. bp_featured_members_user_added & bp_featured_members_user_removed are only using 1 arg $user_id and from xprofile_updated_profile i also only need 1 arg, the $user_id. When the user is logged in page cache is disabled, so no problem. But i need to parge the users page directory under those actions. Could you please give me some help Thank you very much for your time. but does these 3 actions passes $user_id into it ? on my side , I can only ask you to try the code like do_action( litespeed_purge_url, https://www.mysite.com/members/ ) on a direct URL , to see if purge works or not , for how to obtain the user id or its related page URL , thats something I probably couldnt help and you need to get it from buddypress support. Thank you @CacheCrawler very much for your time. Yes all actions passes $user_id. Could i use bp_is_user_profile() (returns true for all the pages i want to purge the cache, and i dont need to pass any arg) somehow? I dont want to use litespeed_purge_all For example do_action(litespeed_purge_url, set_url_scheme( bp_is_user_profile() ) ) or do_action(litespeed_purge_url, bp_is_user_profile() ) or it will not work? Thank you for your help litespeed_purge_url expects a URL , as long as you give it a valid URL, it should work but I am not sure what will bp_is_user_profile() or set_url_scheme( bp_is_user_profile() returns maybe you should try to dump out the values first and check Thank you @CacheCrawler very much for your time. The above code had one small mistake just missing a ) . It is working as expected Could i ask 2 more questions? 1. From the above main members loop page https://www.mysite.com/members/ how can i exclude all dynamic subpages from UCSS URI Excludes? For example, all subpages under /members/joendoe/ or /members/joendoe/submissions/ but not /members/. The /joendoe/ is dynamic . 2. I am trying to cache pages only for subscribers(logged in users). When i set Cache Logged-in Users to ON and Do Not Cache Roles = only Subscriber in unticked how exactly LSCache creates the cached version? Is it a unique page for every subscriber, or is it the same for all subscribers(asking this because maybe more server space is required)? Is it possible to exclude URI members/ from cache ONLY for subscribers? Ideally i would like to serve subscribers the same public cached pages as logged out users get. Thank you again for your help Hi, you can use do_action( litespeed_conf_force, optm-ucss, false ) ) during that page loading , to bypass UCSS sadly no , its global setting , you will generate private cache for each user on each page that under /members/ best regards, Thank you @CacheCrawler very much for your time. I would like to generate the same UCSS under all pages with bp_is_user_profile(). Could i do: add_filter( litespeed_ucss_per_pagetype, function() return bp_is_user_profile() ) what does bp_is_user_profile() returns ? bp_is_user_profile() returns true to all pages of a users profile. For example http://example.com/members/joe/profile/ or http://example.com/members/joe/submissions/ or http://example.com/members/kate/profile/ and so on . All of them have the same css structure . Please see. it shows Is the current page part of a users extended profile? thats not exactly a post type , like page , post, product or something
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference