• Resolved francoc30

    (@francoc30)


    My site is a membership site. I have logged in user name and status displayed on the sidebar and top menu using the membership plugin widget (shortcode).
    When a non-logged-in user browses the public pages, the sidebar shows he/she is not logged in. That is fine.
    Then the same user logs in, the status on the sidebar of the public pages he/she visited earlier still show not logged in. But if she/he visits other pages that he/she has not visited before, the sidebar shows his/her name and logged-in status. It appears to me that after a user logged in, the previous cached pages are still served. This is confusing for users who logged in but on the sidebar shows he/she is not.
    Is there a way or setting(s) that can prevent this to happen?
    I have enabled the following in Page Cache :
    Don’t cache front page
    Don’t cache pages for logged in users
    Don’t cache pages for following user roles (all roles)
    Cache posts page (default)

Viewing 16 replies (of 16 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @francoc30

    Thank you for your patience.
    AS the FAQ clearly suggests, The comment/code blocks should be added to your theme template files as HTML and not within the PHP open (<?Php) and close (?>) tags, as it will cause a PHP to parse error/syntax error. Do not include any sensitive information in your code fragments; the code can be revealed if W3 Total Cache is deactivated, the Page Cache is changed to use an incompatible storage engine, or the defined W3TC_DYNAMIC_SECURITY string value is changed or not defined.
    Also, the <mfunc> replaces the PHP tags so those tags should not be within the code block.
    You should only wrap the part of the code you wish to remain uncached. Once again the best thing to do in your use case is to fire their widget/shortcode with ajax since you are adding the shortcode via widget.

    The Page Fragment caching works like this:
    I’ll skip the procedure for caching method and defining the constant.
    Let’s say you wish to add time and date to your footer. In this case, you will add the time-date code to the footer.php:

    <?php
    echo date("Y/m/d") ;
    ?>

    As you can see the date is echoed within the PHP tags. Once the page is cached, so is the time and date and this is where Page Fragment cache comes into action:

    <!-- mfunc mysecurestring -->
    echo date("Y/m/d") ;
    <!-- /mfunc mysecurestring -->

    I hope this explains it.
    Thanks!

Viewing 16 replies (of 16 total)
  • The topic ‘Cached pages showing for logged-in users’ is closed to new replies.