Last week, as part of our ongoing quest to increase the speed of our website, we were tweaking our WordPress blog, we noticed a couple of things. The first was that there was a large portion of the loading time spent waiting for the database to respond. The second was that the time to first byte, at 641ms, was one of the largest parts of the response time.
After crawling around the interwebs looking for solutions, we basically could not find any advice that did not include moving to a better/faster server. Our research has shown that because time to first byte is the time it takes the server to start sending the data, there are really only three things you can do to reduce TTFB with wordpress;
- Move your website to a faster/better server
- Use a CDN or something similar to reduce the load on the server (repeated requests to a server will increase the TTFB)
- Reduce the time the server spends processing the request for information.
As we are not really prepared to move servers, and change the way our server worked, we thought there was little we could do. However, this morning there was something I noticed, and that was that the Wp_Posts was basically 10MB big. With WordPress’ reliance on MySQL, I knew this would mean trouble for any speed on the database.
Long story short, we found a “Delete Revisions” WordPress plugin, which does exactly what it says on the tin, deletes all the revisions of the posts and pages of your WordPress website. We backup our data every day, so it did not bother us to remove some of the thousands of old revisions from our blog. Some of the pages on this blog have been changed 30+ times over the years, and all that redundant data is stored in the database.
So, we ran the plug-in, and it found some 2500+ redundant revisions. Once we had removed these, it reduced the database by 9.6MB! We then went back to the MySQL and optimised the database. Now WP_Posts sits at a much more comfortable 1.6MB.
After that huge change, we went back to Load Impact, and found our website has gone from a total loading time of 4.94 s to a total loading time of 3.29 s. That is a 33% increase in loading speed. The time to first byte on the first call has gone from 641ms to 329ms, almost a 50% reduction in time.
We have written a more in depth analysis of time to first byte here.