[Resolved] WPEngine Elements/ Generateblocks issue

Home Forums Support [Resolved] WPEngine Elements/ Generateblocks issue

Home Forums Support WPEngine Elements/ Generateblocks issue

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1987480
    Matt

    Hi Guys,

    I’m having an issue with my sites that are on WPEngine.

    I’m using GP Pro and GB pro, and making use of the elements feature to hide/show headers and footers on different pages/templates and when users are logged in/out. Specifically I’m having issues when I make changes to an element and save. Often, when there are multiple pages with the same element, one page will have the new styles, and another will just be broken (ie. no or incomplete styles)

    I have found this support thread on your forum and it seems to sum up the issue.
    https://generatepress.com/forums/topic/footer-block-element-not-rendering-correctly/

    ie. if I turn on in-line styles for Generate blocks, the problem is resolved. So it seems that wpengine cacheing is not clearing the generated external stylesheet. In the example above where I have multiple pages showing different/ broken styles, when I view source I can see that 2 different stylesheets are being referenced, and only 1 actually exists.

    I understand that this might not be an issue with GP or GB, but in many long support sessions with WPEngine the end result is a comment like ‘we can’t support xyz plugin and the way it generates styles, if there is a url or cookie that we can remove from cache, we will do that).

    So, basically, I’m asking you for a bit more information that I can take to WPE and try and get this resolved and working properly.

    Any assistance would be appreciated. Thanks.

    #1989038
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m not sure if this is it, but one issue we’re aware of is when Elements are for logged-in/out users. The stylesheet is generated on the first page visit, so the end result of the CSS generation depends on whether the visiting user is logged in/out.

    It’s something we’re working on a solution for. Thankfully, using the inline option won’t hurt your website at all – you shouldn’t notice any difference.

    Let me know if that makes sense or not ๐Ÿ™‚

    #1989047
    Matt

    Hi Tom,

    Yes that sounds like it could be the issue. I’m definitely seeing the problem under those circumstances (logged in vs out).

    The thing I am seeing on wpengine is that when i make an update to an element, then regenerate the stylesheet (GB and GP) and then clear the wp engine cache, the first page I browse to seems to look right, but then I go to another page with the same element and element display conditions, and the page is trying to reference a different GB stylesheet.. a stylesheet that no longer exists because I regenerated etc.

    Thanks for the response.

    #1990560
    Tom
    Lead Developer
    Lead Developer

    That definitely sounds like some sort of caching isn’t letting go.

    When a page or an Element is saved, it sets a flag (post meta) telling GenerateBlocks to create a new stylesheet the next time the page is loaded. If that post meta field isn’t correct, GenerateBlocks won’t generate a new stylesheet.

    Are you removing query strings on your site by chance? That would prevent the browser from downloading the newly generated stylesheet content.

    #1990564
    Matt

    Hi Tom,

    Definitely not removing query strings. I am using them quite a bit for other functionality.

    #1992015
    Tom
    Lead Developer
    Lead Developer

    Here’s how our stylesheets work:

    1. When a page has GenerateBlocks inside its content, a style-{page-id}.css file is created.
    2. If an Element exists on that page, it will add its CSS to that existing stylesheet.
    3. If no stylesheet exists (no blocks on the page), the Element should add its in the <head> element within <style> tags.

    So, there are two different stylesheets being referenced/created because those two pages have different content. This is expected when using the external stylesheet option.

    When you save something within the content on the problem page, does the query string change in the source? Or does it remain the same?

    I’m trying to think why Elements wouldn’t be adding its CSS to the existing stylesheet. Elements basically gives GenerateBlocks its content during the stylesheet generation so all of the CSS will be generated. As far as GenerateBlocks is concerned, the content within the Element actually exists within the content of the page. If you change a button color on the problem page, does that button color update on the frontend? And the Element still isn’t being recognized?

    Let me know ๐Ÿ™‚

    #1992039
    Matt

    Hi Tom,

    I have setup a staging site and provided details below.

    This is a membership site and the external pages are home, privacy policy, contact us, terms and conditions (links in footer). These pages are all displaying the same header element with the ‘user logged out’ condition.

    You can see that the / and /privacy-policy pages look ok, but the styling is not applied/different on the other 2.

    Side note.. while setting up the User account for you, I also cleared the cache to see what it would do. The home page was originally displaying the header with no styling on the login button or background color, but as this was the first page I viewed after cache clearing and seems to have corrected itself??

    #1993373
    Tom
    Lead Developer
    Lead Developer

    Here’s what I think is happening:

    If you update the page (Terms and Conditions for example), it does two things:

    1. Tells GenerateBlocks to generate a new CSS file on the next page load
    2. Likely tells WP Engine to clear the cache for that page

    #2 is my assumption, because if we click “Regenerate CSS Files” in “GenerateBlocks > Settings”, it doesn’t actually work. My guess here is that the WP Engine cache isn’t aware that we just made a change (obviously), so it holds onto the old cache. So if you click that button, be sure to clear the WP Engine cache.

    Now we have to go back to what I said above: https://generatepress.com/forums/topic/wpengine-elements-generateblocks-issue/#post-1989038

    Once the page is updated, GenerateBlocks knows it has to generate a new CSS file on the next load.

    If I’m logged in and view the page, GenerateBlocks generates the CSS based on the blocks it can see. This means any blocks for logged-out users will not be parsed and the CSS will not be generated.

    If I’m logged out, it’s the opposite.

    So, if I visit the Terms page while logged out, the blocks are parsed and CSS is generated (and cached). If I view it when logged in, the blocks are not parsed and the CSS is generated (and cached).

    As I mentioned, this is a flaw with how GB generates CSS for logged-in/out blocks. We’re trying to come up with a solution.

    For now, you have two options:

    a) Make sure you visit these pages while logged-out for the first time if they need a fresh stylesheet (kind of a pain).
    b) Use the inline CSS method – it won’t make any difference to your performance as it’s all cached anyways, and you won’t have to worry about this issue.

    Hope that makes sense!

    #1993376
    Matt

    Hi Tom,

    Thank you. I really appreciate the thorough explanation and the time you took to delve into the issue and I’m happy with just inlining the css.

    Thanks again.

    #1994366
    Tom
    Lead Developer
    Lead Developer
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.