• 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 - 16 through 30 (of 111 total)
  • Plugin Support qtwrk

    (@qtwrk)

    please explain what’s the step to reproduce it

    Thread Starter hagenb

    (@hagenb)

    1. Go to my website’s “Home” page

    2. Go to “Product Categories” in the Navigation Menu
    3. Go to the Login Page (by selecting “Account – Login” in the navigation menu) and log in using the username and password provided
    4. After you log in you will be redirected back to the “Home” page

    5. Then go back to “Product Categories”. You will notice that the cart is updated (as it should), but in the Menu you will notice that it still says “Login”

    6. When I refresh the page the change takes effect (The menu item says “Logout”).

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

    @hagenb

    I can confirm it and have a almost similiar issue at my page. The issue at my page isn’t WordPress, but the issue is the same. And in deed it is a browser cache issue, but difficult to fix it.

    Please try the following. Place this code on the very top of your .htacces before LiteSpeed marker.

    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} wordpress_logged_in_ [NC]
    RewriteRule ^.*$ - [ENV=CACHECONTROL:true]
    Header set Cache-Control "max-age=0, no-cache, no-store, private, must-revalidate" env=CACHECONTROL

    Notice: The code above is only quick’n dirty solution and is only for testing. If it works @qtwrk should optimize it.

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    Thank you for your reply and help. I placed it in my .htaccess as you said:

    https://yourimageshare.com/ib/VHdlRpGAtE

    But unfortunately, it didn’t work. I “Purged All” and I don’t know if I have to wait for it to take effect..

    Okay, remove this code from .htaccess and let’s try another dirty trick, but only for testing!!!!

    Enable ESI!

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    I removed it, enabled ESI, Purged All, but still the same behavior.

    EDIT: The only difference is, now my cart also doesn’t update after I login.

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

    Horrible… Sorry, I can’t help! @qtwrk, it’s your turn….

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver Thank you for trying.

    @qtwrk If you have any suggestions, I would really appreciate it.

    Do you have any plugin installed that could influence browser cache behaviour?

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    I just went through all the plugins I’m using and I can’t see one that could influence browser cache behaviour.

    I’m going to disable one by one, test as I go and let you know when I’m done. I avoided doing this because of the time it will take, but I guess I have to eliminate the possibility. I will get back to you when I’m done.

    Thread Starter hagenb

    (@hagenb)

    @serpentdriver

    I have disabled all the plugins and changed my theme (just to make sure) and even with it all disabled and the theme changed, I still get the same behavior.

    Thread Starter hagenb

    (@hagenb)

    @qtwrk @serpentdriver

    This seems to be an issue that WP Rocket users also experienced. They have the following “plugin” that solves this issue for WP Rocket.

    Have a look here: https://docs.wp-rocket.me/article/1696-logged-out-cache-displayed-to-logged-in-users

    This can possibly be modified to be used by Litespeed users as well?

    @hagenb

    This is the same code, that I alreayd posted. But with the difference that my code is only active for registered visitors. You can also make this change active all the time, but this change will affect caching behavior. Try the modified code below.

    <FilesMatch "(\.html|\.htm|\.php|\.HTML|\.HTM|\.PHP)$">
        Header set Cache-Control "private,max-age=0,no-cache,no-store,must-revalidate"
    </FilesMatch>

    https://docs.litespeedtech.com/lscache/devguide/advanced/#understanding-response-status-codes-200-and-304

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

    (@hagenb)

    That worked perfectly!

    Can you please explain what you meant with “but this change will affect caching behavior”? Is there anything I should know about when using the above? Can you please explain what it does?

    Follow the posted link.

Viewing 15 replies - 16 through 30 (of 111 total)

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