3 days of testing WordPress Optimization techniques! This is what I found after testing on a site set up specifically for testing WordPress. For context, a couple of weeks ago I set up a new site for a friend using WordPress, she loved it and started adding content. Then she sent me a Whatsapp to say someone complained about the speed of her site. Time to prove them wrong.
After a few days of testing ways to speed up WordPress Optimization, I came to the conclusion that there is no single approach to obtain the best results. Add to the ever-changing network conditions throughout each day and you run tests all day and get different results every time.
What you see above is the most consistent result I could achieve focussing on London as my chosen test location.
To be honest I have never really focussed that much on granular performance. If it appears to load quickly for me and allowing distance and quality of network it should still load quickly enough for everyone else. I was mostly right.
My objective was to determine whether location, control panel, web server, CDN and so made a difference.
I am not going to bore you with dozens of images from tests other than to say again the image above represents my generally consistent best result.
It is important to realise as well that not all websites are equal. If I created a completely static site made purely of HTML files, it would fly across the world with little effort or optimization. WordPress on the other hand is known to be a resource hog in many ways. I will get to that.
Test Conditions used
To keep everything as similar as possible I used Shared Hosting, VPS, and Dedicated. All had the same allocation of resources and used NVMe drives. I carried out the tests using;
On each server I copied across the same backup of this website.
- HostMantis Shared Hosting Account – London – cPanel – Litespeed
- BuyVM Shared Hosting – Luxembourg – DirectAdmin – Apache with Nginx cache
- Hetzner Cloud bare VPS – Germany – Ubuntu/Nginx
- DigitalOcean Cloud bare VPS – London – Ubuntu/Apache
Also used a few different Content Delivery Networks which I get to.
Now I am really not going to bore you with a long technical analysis here, that is not what this site is about, rather I will simply explain what I found. Remember, I really don’t believe one glove fits all here. You need to use trial and error.
One point that is important. Not all hosts are great when it comes to performance. You can do every bit of optimization right but if the host you are on is overloaded and it slows database access or is just a poor service it will impact your site and optimizing it will have a limited effect.
Let me break down my findings as simply as possible.
The general rule of thumb is that if you place your site where you expect the majority of your audience to be. If you are a takeaway in London and you take orders on your website you want that site hosted in London, not the USA for example. The faster the site the better your customer’s experience.
Providing the site itself is correctly set up and your images are well optimized then you likely don’t need to worry about things such as a CDN in the example above.
However, if your audience is broader, across Europe, possibly the world that is when you will want to optimize more to ensure everyone has the best experience possible.
I found that once the site was cached through a CDN location started to matter less. For example, the performance difference between London and Germany was so little it would not adversely affect visitors from the UK or indeed across Europe. The further away you went from the server when testing, it added time due to distance but still coped well.
It is worth noting that once a site is behind a CDN such as Cloudflare, the real IP of the server your site is hosted on is hidden, therefore the true location of your site is hidden from search engines.
So the thought that you need to host a site in the UK for it to perform well in google.co.uk is not the case. Google is smart though, I am using a .uk domain with a site in the English language which gives search engines a hint as to where I may be aiming primarily at least.
Content Delivery Network – CDN
This is an area that threw results all over the place. No CDN is the same that is for sure. To understand why you need to have a basic grasp of what they do.
Basics of a CDN
Using this site as an example, it is hosted in the UK. Now that simply suits me to have it in that location. That said people from all over the world are likely going to visit this site. A visitor in the UK will find it fast to access and browse.
Someone in Asia is not going to have the same experience though. They still need to find their way through the network to get to the UK, request the data, images and so on then send it all the way back to Asia. This will happen for every page they request.
The effect can be painful and put them off spending time on the site. Without a CDN or other WordPress Optimization, a UK visitor will still find the site loads in less than 2 seconds, even on Mobile. The visitor in Asia may find it takes 5 seconds or more. Nobody likes waiting that long for a page on a website.
So the answer is likely to be using a CDN. A CDN has up to hundreds of servers within its network and they positioned throughout the world. The idea is that your website data will be distributed to these servers referred to as PoP’s (Points of Presence).
Once this data distribution takes place, those in Asia will or should find that the time taken for your site to load will be significantly reduced.
There are two ways this can happen which are referred to as either the Push or Pull method.
For a Push CDN, you the content owner is responsible for determining what content is pushed to PoP’s across the network and usually, you can decide which locations the data is pushed to.
This is particularly useful for data that does not change at all or often. For example, a video won’t change, so it is better to push that across a CDN. In the example where our server is in the UK and a visitor from Asia accesses the video, it will take longer for them to get access to it. Perhaps too long for them to wait.
However, if you have already pushed the video to a PoP that is very close to where they are then they don’t need to go all the way to the UK. The CDN will determine that the user in Asia is right next to a PoP that has the video stored and deliver it to the visitor from there saving a lot of time for them.
With a Pull CDN, the CDN itself will decide what and where to distribute your data, not you. This is the most common option, especially for sites like this one that can change frequently.
Again our server is in the UK and we get a visitor from Asia. The CDN checks the closest PoP to the visitor, if it has the information they requested it will deliver it from there. If it does not have the information or perhaps it is out of date it will then request the data from our server in the UK, store it on that PoP and deliver it from there to the visitor.
This will happen all over the world depending on where the visitors connect from. Your site data will eventually end up on many PoP’s, it may not be identical on each one and it may not exist on others as no visitor close to a PoP has ever requested your website’s data from that location.
Take a look at the map above. The server with the website on it is in the USA. There is a PoP in the UK.
So someone in or around Sweden or Italy visits your website. They are directed to the UK PoP which checks if the information they requested is on that PoP.
If it is they will receive the data right away. If not, the UK PoP will go to the USA and get it, add it to the PoP in the UK and deliver it from there.
At no point does either visitor have to connect to the server in the USA.
Ultimately all of this ensures that visitors from anywhere in the world can connect and receive page information from your site faster than without a CDN.
Generally, then it is a good idea to use a CDN. There is a caveat to that. If you have no real interest in visitors outside of the UK accessing your site quickly as the content solely focuses on UK visitors then a CDN can actually make your site slower due to the need to connect via a PoP first. Not that much slower but you may want to test the difference for yourself to see what works best.
The most popular CDN that offers a simple setup and provides a free plan is Cloudflare, start with that first. It is a Pull CDN and really, they have fewer configuration requirements for a beginner.
Depending on the hosting service you use that may determine which Web Server is being run. One of three will be used.
- Apache & LiteSpeed
You cannot control what is used unless you are using your own VPS/Dedicated server.
What I will say is that in my testing, LiteSpeed came out on top every single time. This is not surprising at all. It is an excellent web server and especially true in this case. It has significant WordPress Optimization functions.
If you are using a service that is provided using cPanel or DirectAdmin then most hosts these days use LiteSpeed. If yours isn’t you may consider moving to one that does. But this is my opinion, test and test again because a well-configured server using any of the options above can deliver great results.
LiteSpeed also comes with other benefits which I will come on to now.
A theme can make or break your site. WordPress has so many of them available for free. The issue is that many are poorly designed and once again, you can get everything else right but a poorly coded theme can mean you will never get the best performance from your site.
The only and most important suggestion I have is to do your homework and be prepared to pay for a theme for the best results. I use Blocksy on this site. Out of the box, it returns 100/100 on Google Page Speed Testing. Also worth mentioning that another reason I purchased it is that the support is amazing and it is so highly configurable. But the free version is awesome also.
But even with a great theme you yourself can cause speed issues. For example, changing the site font to use something from Google Fonts means that your visitors have to wait on Google fonts loading on the site from an external location. This adds to the time your page takes to load. So try and avoid doing that and use default fonts where possible.
When setting up your theme the way you want it, really consider whether something you are activating or changing could add to the load time of your site.
WordPress Optimization Plugins
You can pick the right location, the right CDN and have the best Web Server for your site. But it can have little impact on the speed if what you are serving on your website is not correctly optimized.
WordPress has many plugins to help with this. Some free, some paid.
Without caching, every time a visitor comes to your site or view a different page they will have to download the same files over and over again such as styles that are common to every page on your site.
To help with this you can use a Plugin that will cache your site, well parts of it. The issue is that caching can be a complex process, especially for a beginner and mostly because nobody wants to do things manually.
Without getting into a long technical section around this I will say that it is something you should at least install and try to see how it affects your site. It is unlikely you will see no improvement and any improvements you see will apply to your visitors, some more than others.
To be clear, most, in fact, all modern browsers should do some caching for visitors when they visit any website to make it quicker if they return but a plugin can go that bit deeper.
The web server your host uses will determine what options you have but generally, I would try out these. In particular, you should use the LiteSpeed plugin if you have a LiteSpeed webserver. Click the images below for more information.
Something that is incredibly important and can really cause a WordPress site to struggle from a speed point of view is images. Too many, too big, especially on a single page can have dire effects on speed.
Visitors on mobile suffer the most if they have to download a lot of big images. In fact, I have seen first hand some people with a low data plan have their entire month’s allowance eaten up by visiting a website with poorly optimized images. Add to that the search engines will penalize you as well.
Some plugins such as Instant Images are very common these days. It provides a very convenient way to add royalty-free images from a site like Unsplash directly to your blog. The issue is that these images are never well optimized for a website. That is not the fault of Unsplash, images are simply quite often very large.
There are many plugins, again some free, some not that will or at least can reduce image sizes by up to 80% and make them mobile ready and of a size that makes them way more suitable for mobile and of course speeds up your site significantly.
A couple of options to consider, as always you need to test and determine which is best for you. Some are very simple with limited options others like ShortPixel have a lot of options but costs to get the best out of it.
Especially for those that rely on images, maybe you are a photographer it will be important you choose a good image optimizer to ensure compression of images does not automatically mean poor quality results. I was most impressed with ShortPixel. I opted to give them $10 to buy 10,000 optimizations which are way more than I needed but it can be used on any WordPress site you own and the credits never expire.
Check these out. I had good results with them all.
There are many others you could consider that help with other aspects of your site but Caching and image optimization are the most important in my view.
Ok, I think you have a good starting point for your own blog or to try and optimize it more than perhaps it has been. Apart from anything else I see in excess of 2,000 words in this post and I would get fed up by now! 🙂
Go back to the very first image in this post. That was my best consistent results for this website you are viewing.
To bring this a bit more to life and not add more images, here are the load times from other locations. The above image was based on UK performance. Page size and performance grade are always the same.
|Washington DC||881 ms|
Now the issue with testing is that you can get different results every time as there are variables such as network speed, CDN congestion at a particular PoP and so on. But I ran the test many times over a couple of days before I made this post to be sure.
What is clear now is that from nowhere in the world will it take any more than 2 seconds for this site to load. And it is only the farthest location from the server which are close to that 2 second maximum, in this case, Tokyo.
Tools for testing
For those that are not aware, the image above is from a service called Pingdom, but there are others. I generally rely on the following for granular detail. Both have free tiers but are limited to so many tests per day.
GTMetrix has some good options to test your site with the assumption your visitors are running an adblocker, different browsers and you can change the assumed speed of the visitor’s connection. This is the result from GT Metrix as I type this post.
Every test site has a different way of displaying data and looks at different things so you need to spend some time understanding each.
Another tool you can use without limit is Google Page Speed. Either through their website or some browsers including Chrome and edge have the test built into the browser itself and you can run it from there.
The test on the right is from the google website and the left from my browser (Chrome).
What worked best for me?
So finally. Refer back to all the different tests I have done and what set up was the one that gave me the best overall results as shown above?
Well, even I am surprised to be honest. I fully expected a powerful, fast VPS with NGINX as a web server and various optimizations would return the best result. Wrong. My best setup was;
HostMantis cPanel Reseller (UK)
Using Cloudflare free CDN
LiteSpeed Caching Plugin for WordPress
Images all optimized through ShortPixel
I am using the Blocksy Theme on this site
Don’t get me wrong, a good VPS from Hetzner or DigitalOcean with NGINX and even an Apache/NGINX combo did work great.
But what really made the difference was LiteSpeed Web Server combined with the WordPress Optimization plugin they provide to go with it. These two elements were the only different factors in all the testing I did.
So the moral of the story is that you do not need the fastest, most expensive hosting to get the best out of WordPress, you just need good hosting combined with the right tools for the best results!
Apologies for the long post, got carried away. Again this was not intended to give you granular detail of every part of the testing. It was just to give you a guide on what to look at or for when trying to speed up your WordPress site.
One last thing
The speed of your site and improving it can become obsessive, I know first hand. You don’t need your site to be 100/100 on Google Page Speed. Above 50 is ok. It really depends on your site. Some sites need a lot going on within the homepage which means it will never get close to 100.
You need to balance performance with usability. Some go to the extreme of making their site look and feel pretty awful just for speed. Visitors want speed but if they like what you offer they can cope with a bit of a delay.
Have fun with it, don’t stress over it!