• 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 - 76 through 90 (of 111 total)
  • NO! Check your plugins and compair plugin names with directory names in /wp-content/plugins if there is a directory where you can’t see the plugin in Admin.

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

    (@hagenb)

    Ok I will check. Thank you.

    Thread Starter hagenb

    (@hagenb)

    This is the only thing I could find that is related to 86400. Its part of the Woolentor plugin. But even if I disable the plugin I still see the cache-control: public,max-age=86400. I downloaded all the plugins and searched for 86400 and I found this:

    // Set cookie or save user meta
    $cookie_duration = 5;
    $cookie_duration = time() + (86400 * $cookie_duration);

    if ( $user_id ) {
    update_user_meta( $user_id, $cookie_name, $products_list );
    } else {
    setcookie( $cookie_name, serialize( $products_list ), $cookie_duration, COOKIEPATH, COOKIE_DOMAIN, false, true );
    }

    Did you purge the cache after you have disabled the Woolentor plugin?

    Thread Starter hagenb

    (@hagenb)

    Yes I did..

    Okay, the main thing is that we know what the problem is. However, it is up to you to find out what causes this error. From a distance my hands are tied, sorry. Until you find the error, please use the code below. This code defines the default configuration of any PHP application, including WordPress. This means that the mentioned feature of the LiteSpeed web server is retained. It should actually at least overwrite the problem.

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

    (@hagenb)

    This code defines the default configuration of any PHP application, including WordPress. This means that the mentioned feature of the LiteSpeed web server is retained. It should actually at least overwrite the problem.

    Thank you. It looks like I will have to keep this indefinitely as I can’t find what is setting it. I downloaded all my plugins and went through them one-by-one and I could not find what was causing it.

    The only thing I could find is the following, but disabling the plugin and “Purge All” did not fix it:

    public function render_proxy_page() {
    
    $proxy_options = $this->determine_proxy_options();
    
    if ( $proxy_options === [] ) {
    
    // Do not accept any other file than implemented.
    
    $this->set_header( 'HTTP/1.0 501 Requested file not implemented' );
    
    return;
    
    }
    
    // Set the headers before serving the remote file.
    
    $this->set_header( 'Content-Type: ' . $proxy_options['content_type'] );
    
    $this->set_header( 'Cache-Control: max-age=' . self::CACHE_CONTROL_MAX_AGE );
    
    try {
    
    echo $this->get_remote_url_body( $proxy_options['url'] );
    
    }
    
    catch ( Exception $e ) {
    
    /*
    
    * Reset the file headers because the loading failed.
    
    *
    
    * Note: Due to supporting PHP 5.2 header_remove can not be used here.
    
    * Overwrite the headers instead.
    
    */
    
    $this->set_header( 'Content-Type: text/plain' );
    
    $this->set_header( 'Cache-Control: max-age=0' );
    
    $this->set_header( 'HTTP/1.0 500 ' . $e->getMessage() );
    
    }
    
    }

    The CACHE_CONTROL_MAX_AGE is DAY_IN_SECONDS which is 86400 seconds..

    Beside the above, there is nothing I could find.

    Where did you find this constant? In any plugin? CACHE_CONTROL_MAX_AGE

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

    (@hagenb)

    Yes it was in the plugins “Yoast SEO” folder in a file called class-my-yoast-proxy.php.

    Okay, let me check it.

    The CACHE_CONTROL_MAX_AGE is DAY_IN_SECONDS which is 86400 seconds

    Where did you find the value 86400?

    Thread Starter hagenb

    (@hagenb)

    It’s in the class-my-yoast-proxy.php file line 28 : const CACHE_CONTROL_MAX_AGE = DAY_IN_SECONDS;

    I asked you for the value and not the constant name. 😉

    Thread Starter hagenb

    (@hagenb)

    oohhhh.. There is 86400 seconds in a day, so whatever is setting cache-control: public,max-age=864000 sets it for a day.. I hope that is what you meant 😉

    EDIT: The constant is set in what I posted above $this->set_header( 'Cache-Control: max-age=' . self::CACHE_CONTROL_MAX_AGE );

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

    Yes, that want I meant, But how do you conclude that DAY_IN_SECONDS = 86400?

Viewing 15 replies - 76 through 90 (of 111 total)

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