• Resolved abdelkrim1

    (@abdelkrim1)


    ”I want to report a subtle improvement that I believe will help many users.

    In the current version of the plugin, you have the ability to enable “Cache Logged-in Users” for different user roles, which is fantastic. However, looking through the execute-cache.php file code, lines 125–136 append the logged-in username to the $filename. So in short, what the plugin is doing is actually creating a unique cache file for each individual page for every individual user. Which technically is great on low-traffic sites. However, with say a decent size site consisting of 100 pages and 4000 users in that user role, this would end up generating up to 400,000 individual cache files. Let’s assume an average of 100KB per file, you’re talking about generating close to 40GB of data!

    In certain cases, like ours, the site may be optimized to where data on cacheable pages does not include personal information and pages can be cached on a per-role basis rather than a per-user basis. This means that the cache can be greatly improved and optimized by only storing a single copy of those pages for each necessary role. So with the above example, enabling it for that one user role would only generate up to 100 files. So not even 1MB of data. A gigantic savings. ??

    Of course, it should come with a gentle reminder that the same cached content would get served to all the users of that role, but for those that could benefit from it, like us, this could be an extremely helpful improvement.

    The great news is that implementation-wise, you pretty much have all the necessary code already there. You already extract the logged-in user’s roles earlier in the code with breeze_which_role_folder( $value ), so it’s a matter of tapping into that data and grabbing say the first available role.

    if ( ! empty( $folder_cache ) ) {
        $role_name = $folder_cache[ 0 ];
    }

    Then just using that as part of the file name instead of $nameuser.

    All you would have left is to add a simple toggle to the admin page that just enables caching pages for logged-in users on a per-user-role basis this way and you’re all set! ??

    In a dream scenario, the plugin would allow us to specify which URLs can be excluded from being cached this way (similar to how the general exclusions are handled).

    Thoughts?”

    I need help to achieve this. Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter abdelkrim1

    (@abdelkrim1)

    Can you give me the solution for this please?

    Plugin Author adeelkhan

    (@adeelkhan)

    First of all thanks to ask such interesting scenario. I think you have little bit confusion about the functionality of logged in user let me explain. While you enable the option Cache Logged-in Users, its create cache on the basis of role of logged in user rather than number of users logged in as specific role.

    Thread Starter abdelkrim1

    (@abdelkrim1)

    It seems not working for me like that. I tried to logged in as a customer with customer credentials and role and i have visited the website than i have logged in as a second customer with different customer credentials account but the cache from customer one didn’t work for customer two. The both users i have used are customer role

    Plugin Author adeelkhan

    (@adeelkhan)

    Its strange behavior.

    Quite possible it may create conflict with other activated Plugins installed.

    Please deactivate all plugins except Breeze.

    Plugin Author adeelkhan

    (@adeelkhan)

    Apologies for the delayed response. Let me clarify the scenario.

    When the ‘Cache Logged-in Users’ option is enabled in Breeze, it creates caches based on user roles, as mentioned earlier. However, it also generates separate caches for each user session.

    To elaborate, if you log in with the customer role as ‘first-customer,’ Breeze will create a cache specific to ‘first-customer’ with its unique user ID. Similarly, when you log in as ‘second-customer,’ a separate cache is created for ‘second-customer’ with its distinct user ID.

    You mentioned the possibility of applying a functionality where all logged-in users with the same role share the same cache file. However, this approach may pose issues as it lacks the separation of identity for each user, potentially causing problems.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Allow Cache Logged-in User Roles’ is closed to new replies.