Page Cache for logged in Users

When a cache for logged in users enabled how the cache works? Does it cache site per user all it does whole page cache?

On my site, I have a button on each article that allows adding posts to a favorite list (for logged in users). When clicked the process happens through an AJAX request.

When loading the page, if a user has already added an article to his/her favorites, the button will light up.

When Page Cache for logged in users will be active, if a page is being cached by user 1 who has favorites an article, will user 2 (a different device and account) see a highlighted button as well when opening the page because of caching?

  • Nastia

    Hello Dominique

    Hope all is well!

    I have feedback from our developers. I am quoting Ivan bellow:

    Basically, Page Cache does the same thing as for non-logged in users, it just caches once for everyone. Just a note: it never caches admin pages, nor requests other than GET.

    If the button actually never shows that page was favorited to users who did favorite it, this kind of stuff is resolved by making a custom script that will be included in pages and when page loads it will
    just populate relevant button/field with user-specific info.

    So basically it will do:
    - whole cached page loads from the server
    - page contains a small script that will pull via AJAX specific info for user
    - the script pulls data and populates whatever is needed on a page for a user

    Depending on how pages are complex, adding one AJAX request shouldn't be too much overhead, i.e. it's still reasonable to use page caching.

    Hope this will help!

    Kind regards,
    Nastia

  • Dominique

    Thanks for answering.

    I'm not really understanding what's the point of creating a seperated cached page for every user. if all user specific information is being pulled via an Ajax script.

    So if user 1 visits the page it will be cached for him/her only, if visitor 2 visits a page the cache of user 1 won't be used and the page load is exactly the same as for user 1. Right? In that case the caching is only effective when a user visits a specific page twice.

  • Nastia

    Hello Dominique

    Hope all is well!

    The Page cache in Hummingbird will cache the whole site, so the same cached page will be loaded for logged in users; it is not caching pages per user.

    I'm not really understanding what's the point of creating a seperated cached page for every user. if all user specific information is being pulled via an Ajax script.

    In this case, one cached page will be loaded to all users the same, except for the script that will pull the user's information saved in the database.

    Hope this help!

    Cheers,
    Nastia

  • Dimitris

    Hello there Dominique,

    hope you're doing good today and don't mind me chime in! :slight_smile:

    There's been a incorrect statement from Nastia above.

    In this case, one cached page will be loaded to all users the same, except for the script that will pull the user's information saved in the database.

    This isn't true, as there're going to be one cached page for each user, not one cached page for all of them. This is happening because of different content used for different users (there can be a top bar, a username or something else).
    So, the different files is an indication that this working as expected. A different file will be created for the same post for each user. So 1 post for 5 logged in users will generate 5 different files.

    If this is still an issue for your implementation, I'm curious to have a look at it, but I'll need some access details for that. As this is public forum, you should send us your details through our safe contact form https://premium.wpmudev.org/contact/#i-have-a-different-question using this template:

    Subject: "Attn: Dimitris"
    - WordPress admin (login url/username/password)
    - FTP credentials (host/username/password)
    - cPanel/Plesk credentials (host/username/password)
    - specific paths of files of custom implementation
    - link back to this thread for reference
    - any other relevant urls

    Keep in mind the subject line as ensures that it gets assigned to me.

    Warm regards,
    Dimitris

    • Dominique

      Hi Dimitris,

      Thanks for your explanation. I think it's clear to me, but I'm not really satisfied by this.

      I'd have thought that Hummingbird would create one cache file for all logged in users and would pull user specific data via Ajax, or something. I'm not sure how different caching plugins work that way, but a separate file for every user would mean that caching for logged in users wouldn't result in a large gain in speed. Since user 2 doesn't profit from the caching file already generated for user 1.

      • Dimitris

        Hey Dominique

        I'm glad we've sorted this out eventually!
        Yes, this works like this and that's how it should work actually, as it doesn't mean that all user specific data will be pulled via Ajax calls, so the actual content should be cached for each user.
        If your implementation brings all user-specific data via Ajax, then the cached content might be the same, but usually, the content will be different, that's why it works like that.
        Hope that makes sense! :slight_smile:

        Take care,
        Dimitris

        • Dominique

          Hi Dimitris,

          What I get from this is that Hummingbird Page Caching is very unagressive for logged in users, since every user has his/her own cache files. Your method is safe (not viewing data from a different user), but therefore it's also not effective (visitor 1 doesn't profit from cached file of user 1).

          It's good to know, if we want caching for logged in users, we will probably choose an alternative caching plugin because of this.