[Sage 10] Site not loading the first time, but loads after refreshing

So I’ve got the site up and running: https://qa.rechord.xyz/

It might or might not load the first time. For me and others, it doesn’t seem it load the first time they hit the link, but after they refresh it.

Another thing I’ve noticed is that every first load, I get this:

After I refresh it, it loads.

I have no idea why. Its also first time it happen. What could be the issue for this?

This is what the page.blade.php looks like, could this be the issue?


    $flexibleContentPath = dirname(__FILE__) . '\\blocks\\';
{{-- $flexibleContentPath = " /var/www/html" --}}
    $flexibleContentPath = "xxx/wp-content/themes/RechordTheme/resources/views/blocks/";
    //$flexibleContentPath = "C:\\Users\\44775\\Desktop\\WebDevelopment\\Clients\\Level5\\rechord\\wp-content\\themes\\RechordTheme\\resources\\views\\blocks\\";
    $count = 0;


@if ( have_rows( 'flexible_content' ) ) 
@while ( have_rows( 'flexible_content' ) ) <?php the_row(); ?>

     {{-- for ($index = 0; $index <= $flexibleContentLength - 1; $index++) { --}}
    {{-- need to build a custom loop --}}

    <x-section container="{{ $page[$count]['container'] }}" reverseColumnOnMobile="{{ $page[$count]['reverseColumnOnMobile'] }}" paddingTop="{{$page[$count]['paddingTop']}}" paddingBottom="{{$page[$count]['paddingBottom']}}" sectionImage="{{ $page[$count]['sectionImage'] }}" bgColor="{{ $page[$count]['backgroundColor'] }}">
    @if ( have_rows( 'row' ) )
    @while ( have_rows( 'row' ) ) <?php the_row(); ?>

        @if ( have_rows( 'column' ) )
        @while ( have_rows( 'column' ) ) <?php the_row(); ?>
         <div class="w-full lg:{{ $page[$count]['columnWidth'] }}">

                $layout = get_row_layout();
                $layoutConverted = str_replace( '_', '-', $layout);
                $file = ( $flexibleContentPath . str_replace( '_', '-', $layout) . '.blade.php' );

            @if( file_exists( $file ))

               <?php include($file) ?>
                {{-- @include('blocks.' . $layoutConverted)  --}}
                {{-- @include('blocks.', $layoutConverted) --}}
                <?php echo "No file exists" ?>    


<?php $count++ ?>



What exactly are you trying to accomplish here? It seems like you’re trying to pass an entire path to the blade loader, which is not necessary and may in fact be causing problems. Assuming your blades are in your theme folder, just include them based on their relative position inside views directory. I’m also not clear on why you’re swapping out _ and -. If you control the filenames for your blades (which I assume you do), why not just use _ and skip the str_replace() step? Then you could replace the 10+ lines of code you have above with

@include( 'blocks.' .  get_row_layout() )

I don’t know for certain if the above is causing your issues, but it certainly could be since rendered blades are only generated when they’re requested and this rigamarole might be interfering with that.

I do that because dirname(__FILE__) gives an issue, which I believe could be roots problem, which I’ve made a post before. It gives the right file path, but wrong folder, or such, if that makes sense.

So for each project, which I already used this in my other project, I just hardcode the path, I just put XXX for the live server but this works as a code.

The other is just to keep naming conventions straight, since ACF creates this _ and in php I use -, so I just do that.

I have a different project using the exact same code, so I’m 100% sure this can’t be the issue. This is also compiled for FTP, so I believe, I might be wrong, that it should work like an normal wp theme right.

But this isn’t just appearing on the index/page this bug happens in every page.

So, if you go to settings, and permalinks, the error will appear, and you need to refresh, go to ‘read’ page, error will appear and you need to refresh, etc…

So it feels like it might be something else, since that there is definitelly not blade.

  1. What exactly is logged as error when the page fails to load in the PHP logs?
  2. Are you using OPcache (and possibly with invalidation disabled (for performance))?

It founds out the memory was set to 32MB, where’s this used like 38MB? So I set it to higher, and it solved itself!

And yeah, I need to look into logs more often, the error was literally there.

Glad to hear. Please mark your (or my post) as the solution to mark the whole discussion as solved.

This topic was automatically closed after 42 days. New replies are no longer allowed.