Site logo

[Resolved] elements and cache

Home Forums Support [Resolved] elements and cache

Home Forums Support elements and cache

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2135713
    dominique

    Hi there,

    I use GeneratePress Premium and I have two elements :

    – the first with two buttons : Register, Login
    hook : after_header_content
    users : disconnected

    – the second with two buttons : Account, Deconnection
    hook : after_header_content
    users : connected

    The website is very slow, so I use the cache of WP-Optimize (my host suggests to use WP-Optimize).

    The website is now fast but the page comes from the cache and elements don’t update. For exemple, the user is connected but the buttons displayed are : Register, Login as if the user is disconnected.

    Have you a solution to solve this problem ?

    Thanks
    Dominique

    #2135743
    Ying
    Staff
    Customer Support

    Hi dominique,

    I don’t think GP can control how cache plugin works.

    Does this happen only when cache plugin is activated?

    Let me know.

    #2135834
    dominique

    Hi Ying,

    Thanks for your answer.

    Yes, this happen only when cache plugin is activated. No problem when there is no cache instead it is slow, slow …

    I think that it is not about cache plugin works.
    I think that, after it gives the page from cache, il will be useful to execute the code for elements. This needs to intercept event which says « the page is ready » then to run the code for elements.

    Best regards

    #2135840
    Ying
    Staff
    Customer Support

    Not sure what the settings look like in WP optimizer, if there’re exclusion options, can you try follow the instruction here for Autoptimize?

    Let me know if it works.

    #2135851
    dominique

    Yes, there are exclusions but for url.
    It is not possible to use that because I put elements on all pages.

    I excluded the pages for logins or registers (pages after user clicks on login or register button).

    It is also possible to exclude cookies or pages in which there are strings in http header user agent.
    It is written :
    If any of the above strings are in the User-Agent HTTP header, the requested page will not be cached.

    But it is always the page which is excluded and not a part of the page (ie the elements inside the page).

    Thanks

    #2135920
    Leo
    Staff
    Customer Support

    Have you checked with the support team of the caching plugin and see if they can comment?

    Maybe it’s just a setting that needs to be turned off.

    #2136234
    dominique

    Hi Leo,

    Yes I contacted the support team of the caching plugin but at time, I don’t have an answer.
    Everybody is not so reactive that GeneratePress 😉

    I contacted GP because elements are specifics to GP.
    I sent to GP an email with a file with screenshots.

    Thanks

    #2136423
    David
    Staff
    Customer Support

    Hi there,

    as a safety valve for this kind of issue its possible to use some CSS to hide/show the elements.
    Can i see a page where both of the elements are visible ?

    #2136525
    dominique

    Hi David,

    I sent yesterday a mail at wordpress@generatepress.com with screenshots.
    I don’t see a field in the forum to put an upload file.

    Some infos in private information.

    Thanks

    #2136539
    David
    Staff
    Customer Support

    Lets try to resolve the main issue.

    1. Add this CSS:

    body:not(.logged-in) .connected,
    body.logged-in .disconnected {
        display: none !important;
    }

    2. Edit the Buttons Block, and in Advanced > Additional CSS Class(es) you add either:

    connected – for the buttons you want visible when the user is logged in.
    disconnected – for the buttons you want visible when the user is NOT logged in.

    #2136845
    dominique

    Hi David,

    Results of tests :

    If the user is not connected, it is good : each choose in the menu displays the buttons (in elements) : Register / Login.
    Then I connect as admin.

    On the page where I was, the buttons become : Account / Logout (it is normal).
    Then I go on Home and .. the buttons become : Register / Login (it is not normal) and if I click on Login, it says : you are already connected (it is normal).

    What I did :
    1) inside Appearence / Customize > Additional CSS, I put your CSS.

    2) in each element, i put for each button and for the group of buttons, always in block (right side) in in Advanced > Additional CSS Class(es) either connected or disconnected as you wrote in 2)
    The first time, I put that only for the group button (Buttons with s) then as it is not good, I put also for buttons (Button without s) but it is the same : not good.

    Don’t forget that buttons are in elements in which I put the Display rules : connected or disconnected for users.

    Thanks

    #2137217
    Elvin
    Staff
    Customer Support

    Hi Dominique,

    Assuming you really have 2 Block elements with different display rules (one for logged in users, another for non-logged in), the CSS shouldn’t be needed because the elements shouldn’t even appear on the page as the blocks shouldn’t render.

    The display rule for logged in users is basically a is_user_logged_in() and for non-logged in, its !is_user_logged_in().

    The DOM objects would won’t* have to be CSS styled if they don’t appear.

    If the page’s UI doesn’t change regardless if a user is logged in or not, I think you’ll just have to find WP-Optimize’s settings if it has some sort of page-caching. If it’s not there, you may have to look for that on the server’s end.

    #2137635
    dominique

    Hi Elvin,

    It is not an assumption, it is the reality : I have 2 block elements with different display rules.

    WP-Optimize hides an entire page or nothing. So, after it renders the cached page, we need to change the elements.
    David’s idea to change with CSS seems to be a good idea. But there is a problem.

    Is there CSS change happens after WP-Optimize renders the page ? or before ?

    Thanks

    #2137678
    David
    Staff
    Customer Support

    Is there a CSS issue if you disable WP Optimize ?

    One thing you may want to consider is to NOT use the Logged In or Logged Out display rules. Just use the CSS method to hide them. Then there should be no issue if WP Optimize is just caching pages and not messing up the CSS

    #2138708
    dominique

    Hi David,

    I did as you suggested and I saw that when I was connected as admin (with a small line at the top to go to dashboard) then buttons are OK. It is the same if I am not connected. We can say that your CSS is OK (I removed Logged In and Logged Out display rules).

    But I had always problems when I change the choose in menu.

    And I finally found the solution.

    It is a checkbox in parameters of WP-Optimise (ELVIN won).

    I had checked the box : Serve cached pages to logged in users
    It was said : Enable this option if you don’t have user-specific or restricted content on your site.

    I remove the tick and now everything is OK.
    Even my other problem that I reported to David : the third button that sometimes was not good.

    Everything is good now.

    Many thanks to all the team (Ying, Leo, Elvin and David). Wonderful team !!

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.