• 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 - 46 through 60 (of 111 total)
  • Thread Starter hagenb

    (@hagenb)

    Both 😉

    Joker! 😉

    Please undo the last changes in the .htaccess if you are still using it and use this code instead and try again.

    RewriteCond %{REQUEST_URI} ^\/$
    RewriteRule .* - [E=esi_on:1]

    IMPORTANT! Please purge browser cache!

    Thread Starter hagenb

    (@hagenb)

    Please undo the last changes in the .htaccess if you are still using it and use this code instead and try again.

    I replaced it like you said

    IMPORTANT! Please purge browser cache!

    I did. I cleared all cache, including my browser.

    But unfortunately it didn’t work 🙁 I still have exactly the same issue as before.

    In any case, it was worth a try, but the last code change worked?

    Thread Starter hagenb

    (@hagenb)

    Yes, but I changed it a bit, what I’m currently using that is working is:

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

    That changes nothing, because WP has no .htm or .html file extensions. But we could try something else. But I still have to test that. Just in case you want to leave no stone unturned?

    Thread Starter hagenb

    (@hagenb)

    But we could try something else. But I still have to test that. Just in case you want to leave no stone unturned?

    I’m willing to try anything you might think will work.

    Okay, maybe in the afternoon I can do it.

    Here comes the last try, really the last try. 🙂

    Before you add the new code, remove the previous one. Purge your browser cache and remove all cookies. Then navigate to your site and request the startpage frequently, but don’t reload it.

    Add this code on top of your .htaccess:

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

    I have tested it and it works (for me).

    Thread Starter hagenb

    (@hagenb)

    It unfortunately did not work 🙁

    Have you tried this on your test site?

    I have just tried it and it works.

    Thread Starter hagenb

    (@hagenb)

    I did test it, but it didn’t work so I changed it back.

    I’m actually happy with how it is running now. With this in my .htaccess:

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

    I tested the above by clearing browser cache, then I visit my site. All the pages I visit for the first time (logged out) don’t get cached x-litespeed-cache: miss. When I visit the same page again (still logged out) it returns cached pages x-litespeed-cache: hit. Then I log in and the menu gets updated as it should and the user still gets cached pages x-litespeed-cache: hit, unless I have not visited a page before logging in.

    Corect me if I’m wrong, but is this how it should be?

    You are a bit wrong. 😉 The cache status doesn’t matter in this case. It ‘s only about the status code and this must be 200 instead of 304 if the code works.

    I would like to test it myself, but with the last code?

Viewing 15 replies - 46 through 60 (of 111 total)

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