cancel
Showing results for 
Search instead for 
Did you mean: 

TTFB issue only affecting homepage in magento 2.2x Urgent advice please

SOLVED

TTFB issue only affecting homepage in magento 2.2x Urgent advice please

Hello to all with Magento Knowledge,
I have run in to an issue with my new project running magento 2.2 with regards to what I believe to be a Time till first byte delay of which is only affecting my homepage.
I am running my magento store via Managed Cloud Hosting package. My store is set to use varnish cache and I receive great speeds on all pages of my site except for the homepage. 
There appears to be a delay / server wait period of 3 or more seconds depending on when running the speed test and I can't see this issue having effect anywhere else on the site.


I had a previous application running the same site template which I still have access too which does not have such delay on any part of the site.


Could any one please point me in the right direction to reduce this server wait time please. I could not use the previous app as a final site as I was experiencing ongoing issues with Web Setup Wizard in that build, but this time its just the few seconds delay that's the problem everything else is fine, I do see this is as quite significant in terms of client satisfaction when using the site so I would really like to get it resolved as soon as possible.

Thanks in advance. 

 




balloons new.pnghome test.pngresponse headers comparison.pngUntitled.png

1 ACCEPTED SOLUTION

Accepted Solutions

Re: TTFB issue only affecting homepage in magento 2.2x Urgent advice please

Thanks for the earlier advice.

 

Just to update for anyone else struggling with this issue. 


The problem in my scenario was that the Newsletter Block which is part of Plazathemes template was not being cached which was causing the TTFB delay on the homepage. 

 

The solution is to update 
cms_index_index.xml

 

located in:
/public_html/app/code/Plazathemes/Newsletterpopup/view/frontend/layout

 

Edit the block that is not cacheable to become cacheable using the following example.
After magento cache flush the page is fully cached and the page delay and TTFB issue is resolved.

 

The new file looks as follows:

 

<?xml version="1.0"?>

-<page xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


-<head>

<!-- <css src="Plazathemes_Newsletterpopup::css/newsletterpopup.css"/> -->


<script src="Plazathemes_Newsletterpopup::js/jquery.bpopup.min.js"/>

<!-- <script src="Plazathemes_Newsletterpopup::js/js.cookie.js"/> -->


</head>


-<body>


-<referenceContainer name="content">

<block name="newsletterpopup" cacheable="true" template="newsletterpopup.phtml" class="Plazathemes\Newsletterpopup\Block\Newsletterpopup"/>

</referenceContainer>

</body>

</page>

 

View solution in original post

2 REPLIES 2

Re: TTFB issue only affecting homepage in magento 2.2x Urgent advice please

Hey @wellysbham,

 

We'd recommend to enable profiler and take a look what exactly takes 3 seconds (maximally): https://community.magento.com/t5/Magento-2-x-Hosting-Performance/TTFB-issue-only-affecting-homepage-...

 

Here's a link to profiler: https://magento.stackexchange.com/questions/49000/magento-2-is-there-a-profiler

 

This module improves profiler: https://github.com/vpietri/magento2-developer-quickdevbar

 

It is likely that there is a 'complex' block on the main page, which possibly loads the heavy collection or something of the kind. It must entirely come from the full page cache. Make sure to check this first as well. 

 

There is also a chance that 3rd party extension block is used on the main page, which 'disables' full page cache.

Take a look here to learn more: https://magento.stackexchange.com/questions/92923/magento-2-what-determines-if-a-request-is-full-pag...

 

Nore details about cache are here: http://devdocs.magento.com/guides/v2.0/config-guide/varnish/config-varnish-final.html. You can learn there how to check what actually works on that page.

 

Header 'X-Magento-Cache-Debug' with HIT value means that the page entirely came from the full page cache. You can check it out right in your browser (developer mode must be enabled!).

Something like that: https://gyazo.com/da6b101f9a425c1d86fde6e4e71cfa29

 

You might also want to take a look at this article to learn more about the full page cache: https://alanstorm.com/magento-2-full-page-caching-code-points/

And this one: https://inviqa.com/blog/how-full-page-cache-works-magento-2

 

---------------------------------------------------------

If you've found one of our answers useful, please give 'Kudos' or 'Accept as Solution'.

Re: TTFB issue only affecting homepage in magento 2.2x Urgent advice please

Thanks for the earlier advice.

 

Just to update for anyone else struggling with this issue. 


The problem in my scenario was that the Newsletter Block which is part of Plazathemes template was not being cached which was causing the TTFB delay on the homepage. 

 

The solution is to update 
cms_index_index.xml

 

located in:
/public_html/app/code/Plazathemes/Newsletterpopup/view/frontend/layout

 

Edit the block that is not cacheable to become cacheable using the following example.
After magento cache flush the page is fully cached and the page delay and TTFB issue is resolved.

 

The new file looks as follows:

 

<?xml version="1.0"?>

-<page xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


-<head>

<!-- <css src="Plazathemes_Newsletterpopup::css/newsletterpopup.css"/> -->


<script src="Plazathemes_Newsletterpopup::js/jquery.bpopup.min.js"/>

<!-- <script src="Plazathemes_Newsletterpopup::js/js.cookie.js"/> -->


</head>


-<body>


-<referenceContainer name="content">

<block name="newsletterpopup" cacheable="true" template="newsletterpopup.phtml" class="Plazathemes\Newsletterpopup\Block\Newsletterpopup"/>

</referenceContainer>

</body>

</page>