Problem description
- Your website is normally very fast to load, but suddenly or recently it takes 10+ seconds to load a single page (which could result in an error at the end, or the page loading normally).
- Your website is loading slowly.
- WordPress is slow.
- It might take 30-60 seconds to finish loading and then either load the page or result in a timeout error or gateway error
Note: For the purposes of this article, when we say slow, we don't mean for all resources to load on the page, rather there's no sign of the site loading at all in the browser until at least 8-10 seconds of waiting.
Problem Resolution
There's a few reasons this issue can occur. Here's the list along with their solutions:
Your website is under heavy load.
In this case the page will load, just a bit slower than usual. Wait 5 minutes and check the results again.
If you're using shared hosting and this happens something like once or twice a week for just a minute or two at a time, this is generally expected.
If you have a dedicated server or VPS, ask whomever is managing your server to look into the web server logs and/or monitor the site when under load to determine the cause.
You're using an old PHP version
Generally speaking newer versions of PHP improve performance. If your site can run the latest version, we recommend using it. See our guide here to changing the PHP version.
Are you using W3 Total Cache with Object Caching?
We like W3 Total Cache's static page cache. And it's object cache - when integrated with redis on a VPS - works great as well. However if you use its Object Cache with the disk engine option, it can feel a bit faster at the start, but a few hours (or a few days) after enabling it, things can slow to a crawl. We know this happens because of the excessive IO resources required to power the disk based object cache; it can even bring a powerful NVMe RAID setup to its knees.
If you're on a VPS, install a redis daemon, then configure W3's Object Cache to use redis for optimal performance.
If you're on shared hosting you will likely find no object cache to work great thanks to our customized database caching configurations. However if you have a large number of database queries occurring on each post/page request, you can also try the Docket Cache plugin to help reduce the query processing time.
Your theme allows full resource processing on 404 pages
See the part about "Any Theme's Custom 404.php" in our discouraged WordPress plugins and themes article for a solution to this issue.
Note: By default we automatically handle high performance 404 processing unless you've excluded 404 page performance for your domain.
There is code where there shouldn't be code
Check the index.php file and (for WordPress) wp-config.php file to see if there's any code that shouldn't be there. That code is likely trying to access a resources at a URL that it cannot reach. We have occasionally seen this with malicious code injected into the top of index.php. It has also been seen with certain API configurations.
Does the page eventually load?
If the page eventually loads and nearly-always after the exact same interval (ex: 20 seconds), inspect the page for glitches or missing elements. For example if the problem is with a social media widget, you might find that the widget never loads on the page like it should. Then you can go specifically to that plugin and disable it to solve the problem without having to scan through each of your plugins one-by-one.
This is not as common any longer since most of this type of code has been moved to asynchronous loading.
If none of the above apply and if the page never loads and instead you get a Gateway or timeout error, please proceed by following our guide to troubleshooting Gateway errors here.