Slow Initial Page Load
-
Hi,
I hope someone will be able to shed some light on my situation. I have a WooCommerce installation that has what I find to be a slow initial page load time. Due to caching and the use of CloudFlare all subsequent loads of the page after the initial load are quick.
I am using Shared Hosting and I was wondering if this could be the reason that the initial load time is slow (usually around 3-5 seconds). The main file that is causing this load time is the admin-ajax.php file (between 2-3 seconds).
Using Google PageSpeed the main area for improvement is “Reduce initial server response time” which is why I am thinking that my issue is related to my hosting provider.
My hosting provider is convinced that the issue is related to a plugin and/or theme but I do not think that is the case. Any insights on this, I have exhausted all avenues and I do not really have any inkling as to what could be causing my issue.
Thank you, any help is appreciated.
The page I need help with: [log in to see the link]
-
I am literally having the exact same issue. Leave the site for a period, with no activity, and it takes an excessive amount of time to load the first page. Subsequent pages load fast.
I recently upgraded the php version on my site and that’s when I started getting the issue. Is this something you have done recently? If so: I actually fixed the TTFB problem and the initial server response time by manually reinstalling ALL my plugins and themes. I noticed that a plugin could be active, and I’d get the server response time. I’d then reinstall the same plugin and it would be much faster.
I am still having the issue with the site taking an excessive amount of time to load after a period of inactivity though…
I am with Siteground, who have been saying the same thing to me. Not a server issue, related to plugins etc. I actually think they are correct, because I actually tried migrating to Dreamhost yesterday and had the exact same issue. I made a Reddit post here to try to figure out the problem https://www.reddit.com/r/webhosting/comments/hg73p9/do_hosting_providers_siteground_in_particular/ – some useful info, but I am convinced that there is something else going on here. Perhaps it is related to cache.
Where I am now with it: I am using WP Fastest Cache for my caching. I actually had a lot of caching included RAM and memcache enabled in my Siteground cPanel. I read that this can actually interfere with things, so I have deactivated them to see if it helps. Now I am just waiting for an hour or so before I try again.
I just tested your link and it is indeed taking a long time to load first time. This is exactly what I am experiencing. I think it could well be related to Woocommerce also, as my tests seem to suggest.
Wow ok, thanks for the great info. After reading your post and the other posts you referenced, I tried a few things and once a removed a few things from my admin-ajax.php that I found weren’t really doing anything, everything seemed to speed up.
Please have a look at the link again and let me know what you think. The admin-ajax process still takes around 2-3 seconds according to GTMetrix but it seems now that it doesn’t affect the loading of the page.
Thanks again!!
@jbaranello No problem, I hope it was helpful. It’s a very frustrating issue.
I tried your link again, and it actually took about 10 seconds to load :/ I’ve been racking my brains on this some more for the last week and I think i have actually solved it for my site… whether it would work for you I don’t know.
For me, it looks as if there were 2 database tables that were causing the big TTFB… wp_posts and wp_options. Seems throughout the years all the different plugins I had activated then deleted and the many different re-stylings of my site actually added a LOT of rubbish into these 2 tables.
I was able to determine this by using query monitor. I left the site for a day, then came back whilst logged in as admin with query monitor active and saw which queries were taking the longest.
I had a crazy amount of data in there so the only option for me was to completely reset and build the database back up from scratch. I tried ‘Advanced Database Cleaner’ which was useful, but didn’t make much tangible difference to the load speed.
With regards to your site… I can confirm that it was only that initial load that was so slow, not the subsequent loads. I tested your site at https://gtmetrix.com/reports/voltechrebuilders.com/BicblRZ8. No high TTFB there, but I assume if we left it for a while there would be.
I don’t know if this is a new site or something that might have built up a lot of rubbish in the database over a few years, but it seems that was what had happened to me. I think the high TTFB after a period of inactivity could quite possibly be a database related issue.
- This reply was modified 4 years, 4 months ago by Anonymous User 16358193.
Okay, I can confirm that even after resetting the database entirely, the issue still occurs for me.
New install of WordPress, new database only Woocommerce installed. Huge TTFB on first load after 1 hour of inactivity.
Are Woocommerce going to respond?
It is a new site (B2B) so won’t have a crazy amount of visitors, just my current customers. I already have over 1500 products in there, which gets updated nightly from our in house inventory program. I am pretty sure the database does have some bloat, I do try to clean it up as often as I can (I use WP Rocket for Caching as well as database cleanup). I recently activated OpCache in my cpanel which I thought helped a little. I basically use WP Rocket for browser cache, css minification, etc. Using OpCache for PHP Script Caching. Trying to setup Memcached for Object Caching now hopefully that will help a little as well.
Also when I had posted my last reply saying I removed some code from my ajax-admin.php which helped the issue a little, this is the code I was talking about. For some reason it came back and I am sure that you visited the link after it came back. Can anyone tell me what this code is for and which plugin uses it?? For me it looks like it doesn’t do anything at all.
if ( is_user_logged_in() ) { // If no action is registered, return a Bad Request response. if ( ! has_action( "wp_ajax_{$action}" ) ) { wp_die( '0', 400 ); } /** * Fires authenticated Ajax actions for logged-in users. * * The dynamic portion of the hook name, <code>$action</code>, refers * to the name of the Ajax action callback being fired. * * @since 2.1.0 */ do_action( "wp_ajax_{$action}" ); } else { // If no action is registered, return a Bad Request response. if ( ! has_action( "wp_ajax_nopriv_{$action}" ) ) { wp_die( '0', 400 ); } /** * Fires non-authenticated Ajax actions for logged-out users. * * The dynamic portion of the hook name, <code>$action</code>, refers * to the name of the Ajax action callback being fired. * * @since 2.8.0 */ do_action( "wp_ajax_nopriv_{$action}" ); }
Thanks
Hey Cure,
I removed that code again, please check the link again and let me know if the loading time is still the same.
Thanks
Well it seems I need the code, I start getting some issues on the back-end in the plugin and theme directory as well as some functions with WP Rocket.
I think what is slowing down the page load is that since there are no actions registered it generates a bad request response.
My page load is definitely faster when I remove that code. Anyone have any ideas on how I can optimize it?
Thanks
Unfortunately I am very unfamiliar with how Ajax works, so I don’t know what that code does.
Just tried your site at the link you originally posted and load time was pretty fast now though.
Spoke too soon, I clicked through to your privacy policy page and saw a TTFB of about 7 seconds…
If I’m correct, the TTFB is usually due to a lot of database queries, perhaps by the WordPress plugins. I would recommend at this point deleting plugins then activating one by one to try and find the culprit.
Are you using any page builder?
- This reply was modified 4 years, 4 months ago by Anonymous User 16358193.
Yeah I know, the page load speed is spotty. Sometimes its fast, sometimes it is not, I am assuming all depends on whether it is served from cache or not.
I have tried deactivating the plugins one by one already and didn’t see any speed improvements. I am working with my hosting provider to see what they can do on there end to speed up database queries and such. Apparently my hosting plan does not include Redis or Memcached so object caching is no go for now.
I am using Elementor as a page builder.
Thanks
Have you considered that the problem could be due to Elementor?
I was running Elementor + Woocommerce too, trying for ages to find the cause and it looks like that could be what it was. TTFB after period of inactivity seems to be gone now.. hopefully stays that way.
I’d recommend turning it off, then seeing if it goes away to determine whether it is indeed Elementor.
Very annoying if you’ve designed the whole site with it, like I have! Have resorted to using the Flatsome Theme’s built in UX builder.
I tried what you suggested and I don’t really see a difference. My GTMetrix score was actually better with the Elementor plugin Activated lol.
I think I will try a better hosting plan and see if that helps. I have pretty much exhausted all my other options.
Thanks again!!
Hey Cure,
I deactivated and re-activated all my plugins and also redid my caching plugin setup. I noticed that not having the “Combine CSS Files” and the “Combine JavaScript Files” seemed to fix my problem for now lol.
I will try again tomorrow and see if the performance is consistent to what I experienced tonight.
Can you please confirm this??
Thanks again for your help!!
Yeah looks like this issue is no longer present on your site. Fingers crossed it stays that way.
Very strange that it was that that was doing it, perhaps a conflict with your hosting or another plugin somewhere.
Glad you got it sorted!
Thank cure, Ill keep you updated as to whether or not this situation changes.
As a side note it seems that one of my issues still is not fixed. My inventory lookup tool which I created using the wpdatatables plugin still takes forever to load. The initial page load seems OK but the SQL queries that prepare the data for searching seem to take a good 10-20 seconds before they are searchable.
Do you mind confirming this for me? Try searching 13893 in the “Part Number” search box and 12308 in the “Interchange” search box at the following link:
https://voltechrebuilders.com/info/customer-resources/inventory-lookup-tool/
I have already contacted the developer about this issue and they seem to think it is a hosting problem as each of the tables the query is searching is over 5000 rows.
Thanks and let me know what you think!
- This reply was modified 4 years, 4 months ago by jbaranello.
- The topic ‘Slow Initial Page Load’ is closed to new replies.