• Resolved hagenb

    (@hagenb)


    Apologies for the long post, but I have to explain everything to get the issue I’m experiencing across.

    Side note – I opened a ticket on litespeedtech but was told to post here. https://www.litespeedtech.com/support/forum/threads/issue-with-cache-on-home-page-for-logged-in-users.21347/

    I’m using “User Menus – Nav Menu Visibility” plugin to display “Login” for users that are logged in and “Logout” and “My Account” for users that are not logged in.

    The problem is that after the user logs in, they are redirected to the “Home” page, if they look in the menu “Logout” will appear (as it should), but if they go to another page and return to the main page, the menu shows “Login” again. They have to manually refresh the page for it to be fixed.

    Disabling cache in the plugin or from CPanel does not fix the issue, but adding the following in my .htaccess does:

    # Begin LSCACHE

    Header set Cache-Control “no-cache, no-store, must-revalidate”

    Header set Pragma “no-cache” Header set Expires 0

    # End LSCACHE

    I have seen this issue being reported on other Cache plugins as well, like this one has exactly the same issue I have – https://ww.wp.xz.cn/support/topic/cache-page-is-being-displayed-to-logged-in-users/

    Any help would be greatly apprieciated.

    Thank you.

Viewing 15 replies - 31 through 45 (of 111 total)
  • Thread Starter hagenb

    (@hagenb)

    @serpentdriver So basically it is telling the browser not to cache any files with those extensions, for all users?

    Basically yes…..

    But it doesn’t influence the server side cache. All in all this code forces to download the data from the server although the data are in browser cache, but this is not a cache plugin issue. This is the “nature” of HTTP.

    Thread Starter hagenb

    (@hagenb)

    I guess I can narrow it down even more, rather than excluding all the .html and .php. I will do some more testing tomorrow.

    I want to thank you for your swift replies and willingness to help.

    My first code already tried to narrow it down and should make the change for cache-control only for logged-in users, but the issue already starts before login.

    The reason for this issue is based on a LiteSpeed web server feature. The LSWS takes advantage of a technique available in the HTTP protocol. This technique is used to influence the loading behavior of the main document by telling the browser whether it should load the requested source or whether the browser should use the data from its browser cache because nothing has changed since the last request. Sounds positive at first, because it has a beneficial effect on the loading time. In this specific case, however, this has disadvantages. If a user is not logged in, the browser remembers that it does not have to load the accessed data again. After logging in, the user is redirected to the start page. However, he has the data for the start page in the cache because the web server has told him in advance that the data does not have to be reloaded again. This explains why a registered user sees “Login” in the account menu, precisely because this is the content from the browser cache.

    The problem now is that the changed cache behavior is very difficult or impossible to narrow down. To do this, the web server would have to know before the login page is called that the user wants to log in. If the web server knew this, it could tell the browser in advance that it would have to reload the page accessed when it visited it again.

    At the moment I can only think of 2 solutions:
    1.) You only change the cache control parameters for the start page. All other pages remained unaffected by this change.
    2.) You append a $_GET parameter to the forwarding URL after login, e.g. ?12345678. This parameter forces the browser cache to reload the page data from the server.

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    Thank you for the detailed explanation. Things make a lot more sense now. Unfortunately, the 2 suggestions won’t work because the issue is not only related to the start page. It’s all pages visited before the user logs in.

    The thing I can’t get my head around is, how is it possible that more people haven’t raised this issue… There must be thousands of membership WordPress websites running on Litespeed servers.

    the 2 suggestions won’t work because the issue is not only related to the start page. It’s all pages visited before the user logs in.

    Why not? Let’s narrow it down to start page. This would have no big impact and would only affect the homepage.

    There must be thousands of membership WordPress websites running on Litespeed servers.

    I don’t think so. This issue only happens

    1.) on startpage and if startpage has already been requested before login

    2.) with 3rd plugin for login/register.

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    Apologies for the late reply, I did not get a notification for your last message.

    Why not? Let’s narrow it down to start page. This would have no big impact and would only affect the homepage.

    The problem is not only related to the home page, it’s related to all the pages visited before logging in. If I visited, let’s say page1, page2, page3, and then log in, the problem will be on those pages and those pages only. I will have to refresh them before the menu gets updated. On the other pages I didn’t visit (before I logged in), the menu is updated (as it should be).

    2.) with 3rd plugin for login/register.

    I disabled all my plugins yesterday and switched to one of the default themes (twenty twenty), then tried logging it with the “default” login and the issue was still present.

    The only plugins I did not disable were “Elementor Pro” (I kept this enabled because I created my menu with it) and “User Menus – Nav Menu Visibility” (This is used to determine if users are logged in or not and change the menu accordingly).

    Apologies for the late reply, I did not get a notification for your last message.

    I’m sorry, but I was so engrossed in my work to build the best and fastest cache crawler that I completely forgot about you! Ashes on my head! 😉

    The problem is not only related to the home page, it’s related to all the pages visited before logging in.

    Right, but you said that you are always redirected to the start page after logging in. So it is enough to focus on the start page.

    I disabled all my plugins yesterday and switched to one of the default themes (twenty twenty), then tried logging it with the “default” login and the issue was still present.

    Hm… The plugin support has to deal with this.

    Thread Starter hagenb

    (@hagenb)

    I’m sorry, but I was so engrossed in my work to build the best and fastest cache crawler that I completely forgot about you! Ashes on my head! 

    No need to apologise. I’m grateful for you taking the time to reply.

    Right, but you said that you are always redirected to the start page after logging in. So it is enough to focus on the start page.

    I have contacted my host and they will have to come in contact with Litespeed as I have tried what I can from my side. I will leave it as is for now, but I can no longer break my head over something I don’t have extensive knowledge about. I will post an update if I have any important updates.

    I would like to thank you @serpentdriver for all the time and effort you put into this. You are awesome!

    In my mind there is nothing fix, but cache plugin should get an extra function. This function is for WP only that have a login and does the same what I gave you with the code in .htaccess. There is no other way to “fix” it.

    Thread Starter hagenb

    (@hagenb)

    @qtwrk

    Please have a look at this.

    Thank you @serpentdriver

    Are you ready for a last “trick”? 😉

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    Are you ready for a last “trick”? 

    Sure?

    • This reply was modified 3 years, 4 months ago by hagenb.

    Shure? or Shure!

Viewing 15 replies - 31 through 45 (of 111 total)

The topic ‘Litespeed causing issue with menu’ is closed to new replies.