We’ve published a lot of tutorials over the years with ways to optimize and speed up WordPress. But sometimes it can be confusing trying to find everything you need in one place. So today we’re going to share with you everything we know about turbocharging WordPress, over 15 years worth of experience and hard lessons learned, all in one ultimate guide. Whether you’re just starting to use WordPress or are a seasoned developer, we promise you’ll find something useful in this guide!
Over 35.2% of the web is now powered by WordPress. While this is awesome, it also means there are thousands of different themes, plugins, and technologies all having to coexist. For the everyday WordPress user, this can quickly turn into a nightmare when their site starts to bottleneck and they don’t know why or even where to start troubleshooting.
In our previous guide on page speed, we went over a lot of the fundamentals of performance and how it can have a huge impact on the success of your business. But today we’ll be diving into applicable steps you can take right now to see improvements on your own WordPress sites. We’ll also share some resources that have been invaluable to us.
WordPress Site Types: Static or Dynamic
Before we dive into the optimizations, it’s important first to understand that not all WordPress sites are the same. This is why a lot of users have problems, as you can’t go about tackling every issue the same way. We always give WordPress sites a classification: static or dynamic. So let’s first explore the differences between these two types of sites.
Mostly Static Sites
Static would typically include sites such as blogs, small business sites, lower volume news sites, personal, photography, etc. By static, we mean that the data on these WordPress sites is not changing very often (perhaps a couple of times a day). Even most of our Kinsta site would be considered a static website.
This becomes incredibly important as many of the requests can be served directly from cache on the server at lightning-fast speeds! Don’t worry; we’ll dive into the topic of caching in length further below. This means they will have fewer database calls and not as many resources will be needed to achieve google performance.
Highly Dynamic Sites
On the flip side, we have highly dynamic sites. These include sites such as eCommerce (WooCommerce or Easy Digital Downloads), community, membership, forums (bbPress or BuddyPress) and learning management systems (LMS). By dynamic, we mean that the data on these WordPress sites is frequently changing (server transactions are taking place every few minutes or even every second). This means that not all requests to the server can be served directly from cache and require additional server resources and database queries.
These sites also typically have a large number of concurrent visitors and sessions. On an informational or corporate WordPress site which is mostly static, a visitor might stay for five or 10 minutes until they find what they need (and this is a high number, usually bounce rates are much higher). On dynamic sites, you have the opposite happening. Visitors typically come to the site to engage with something or someone. If they’re going through an online course, it’s not unusual for them to stay for hours.
You can see where this is going. The concurrent visitors connected to your WordPress host adds up fast. To make it worse, you then have a large number of concurrent visitors on top of an “uncacheable content” problem.
Choose High-Performance WordPress Hosting
A WordPress host is a company that stores all of your website’s data. You sign up for a plan and all your images, content, videos, etc., reside on a server sitting in the host’s data center. The WordPress host gives you an easy way to access the data, manage it, and route it to your visitors. Pretty simple right? Well, not quite.
There are three very different types of WordPress hosts you’ll encounter around the web. Let’s dive into the pros and cons of each. It’s important you choose the right one from the beginning, otherwise, you’ll simply cause yourself headaches and wasted time down the road.
1. Shared WordPress Hosting
The first and most popular type of WordPress hosting is what we call “shared hosting.” These include the largest hosts in the industry such as EIG companies like Bluehost and HostGator as well as providers like Siteground, GoDaddy, and InMotion Hosting. They typically utilize cPanel, and the average customer usually pays between $3 to $25 a month.
Anyone using this type of hosting will at some point experience slowness, it’s just a matter of time. Why? Because shared hosts tend to overcrowd their servers, which in turn can impact the performance of your site. Site suspensions or seeing frequent 500 errors are common things you’ll experience as they have to place limits on everything and consolidate resources to survive. Or even worse, website downtime. Even though you don’t know it, your WordPress site is most likely sitting on the same server as 200+ other people. Any issues that pop up with other sites can trickle over into your site.
No matter how you do the math, after expenses, $3 a month isn’t generating any revenue for the hosting company. Especially when you attribute support into that. One support ticket and they’re already in the red. The way they make a lot of their money is on upselling and hidden fees. These upsells include things like migrations, domain registrations, SSL certificates, etc. Another common tactic is to provide huge signup discounts. But once the renewal comes around, you get the real bill.
Most of these hosts offer what they call their “unlimited resources” plan. You have probably all seen this. Well, there is no such thing in the real world as unlimited resources. What hosts do behind the scenes is throttle the clients using up a lot of the resources. This, in turn, ends up with those angry clients leaving, making room for more clients that don’t use a lot of resources. In the end, you have a vicious cycle of the hosting company pushing cheap plans and signing up customers who they hope won’t use a lot of resources and will purchase upsells.
Customer service and support with shared hosting are almost always subpar due to the sheer volume of sites vs. support representatives. Shared hosts have to spread themselves very thin to even make a profit and this usually leads to an unpleasant experience for the client.
Make sure to check out an in-depth article from our CFO on the shocking truths behind how cheap WordPress hosting really works.
2. DIY VPS WordPress Hosting
The second type of WordPress hosting is DIY VPS, or “Do it yourself on a virtual private server.” This crowd is typically made up of bootstrap startups and users with a little more development, server management, and WordPress experience. They are the DIY crowd. These folks are typically still trying to save money, but they are also usually concerned with performance and realize its importance in the success of their business. Commons setups might include using a third-party VPS provider such as Digital Ocean, Linode, or Vultr; along with a tool like ServerPilot to manage it more easily.
A small VPS from DigitalOcean starts at $5 a month and the popular plan at ServerPilot starts at $10 a month. So depending on your setup, you could be looking at a cost of between $5 to $15 or more a month. The DIY approach can cut costs, but it also means that you are responsible if something breaks, and for optimizing your server for performance.
The DIY approach can be great, but it can also backfire on you if you aren’t careful. Don’t go this route if you aren’t tech-savvy or just because you want to tinker! Your time is worth money and you should be spending it on growing your business.
3. Managed WordPress Hosting
The third type of hosting is what we offer at Kinsta and that is managed WordPress hosting. These types of hosts handle all the back-end server related tasks for you, along with providing support when you need it. They are typically fine-tuned to work with WordPress and usually include features such as one-click staging environments and automatic backups. Their support teams will be more knowledgeable when it comes to knowing their way around the CMS as they are focused on one platform on a daily basis.
If you want to save time, managed WordPress hosting is the way to go! 👍
Plans for managed WordPress hosting typically range anywhere from $25 to $150 a month or more depending on the size of your site and needs. Large companies like jQuery, Intuit, Plesk, Dyn, NGINX, and even The White House are all using WordPress to host their website. Some popular managed WordPress hosts you are probably familiar with, or maybe also are currently using include WP Engine, Flywheel, Pressable, Media Temple, Pressidium, and Pagely.
Kinsta Takes a Different Approach
Kinsta however, takes managed WordPress hosting to the next level. Our hosting platform doesn’t fall into any of the traditional hosting categories. Our entire infrastructure is built on Google Cloud Platform and is different from traditional shared, VPS, or dedicated infrastructure.
Every WordPress site on our platform runs in an isolated software container that contains all of the software resources required to run the site (Linux, NGINX, PHP, MySQL). This means that the software that runs each site is completely private and is not shared even between your own sites.
Each site container runs on virtual machines in one of multiple GC data centers. Each machine has up to 96 CPUs and hundreds of GB of RAM. Hardware resources (RAM/CPU) are allocated to each site container automatically by our virtual machines on an as-needed basis (a neat feature we refer to as auto-scaling).
Every year Review Signal releases their WordPress hosting performance benchmarks, and we are proud that five years in a row, Kinsta has proven to be the best company across all tiers! And not just on one or two of our plans, but every plan, from Starter all the way up to Enterprise. 🤘
We also don’t have level 1 or level 2 support reps. Our entire support team is made up of WordPress developers and Linux hosting engineers many of whom have managed their own servers, created themes and plugins, and contributed back to core. This ensures you’ll receive expert advice from someone who actively uses and develops with WordPress.
You get to chat with the same support team members that back our Fortune 500 and enterprise clients. We are so picky about the quality of our support team that we only hire less than 1% of applicants who apply. You won’t find better support anywhere else!
To learn more about why you should choose Kinsta for managed WordPress hosting, read why us – how Kinsta is different. But regardless of who you choose as your hosting provider, you should always look for these following server features to ensure your website runs as fast as possible.
PHP 7 or Higher for the Best Performance
PHP is an open-source, server-side scripting and programming language that’s primarily used for web development. The bulk of the core WordPress software is written in PHP, along with your plugins and themes, which makes PHP a very important language for the WordPress community. You should ensure your WordPress host offers at least PHP 7 or higher.
There are different versions of PHP that your host will provide you on your server, with the newer PHP 7.3 offering huge performance improvements.
In fact, in our recent PHP benchmarks, if you compare PHP 7.3 to PHP 5.6, it can handle 3x as many requests (transactions) per second! PHP 7.3 is also on average 9% faster than PHP 7.2. This can also impact your WordPress admin dashboard responsiveness.
Faster speeds plus improved security, is why Kinsta always offers the most recent versions of PHP. You can change PHP versions with a single click.
And be wary of any WordPress hosts offering HHVM as an alternative to PHP. HHVM is no longer a suitable solution for WordPress hosting.
Pick a Host That Uses NGINX
Behind the scenes, every WordPress host uses a web server to power your WordPress sites. The most common choices are NGINX and Apache.
We strongly recommend going with a host that uses NGINX because of its roots in performance optimization under scale. NGINX often outperforms other popular web servers in benchmark tests, especially in situations with static content or high concurrent requests, which is why Kinsta uses NGINX.
Some high-profile companies using NGINX include Autodesk, Atlassian, Intuit, T-Mobile, GitLab, DuckDuckGo, Microsoft, IBM, Google, Adobe, Salesforce, VMWare, Xerox, LinkedIn, Cisco, Facebook, Target, Citrix Systems, Twitter, Apple, Intel, and many more. (source)
According to W3Techs, Apache powers 44.0% of all websites, making it the most widely used option. But if you look at the most popular web server among high-traffic websites (top 10,000), NGINX powers 41.9% of them, while Apache only powers 18.1%. It’s used by some of the most resource-intensive sites in existence, including Netflix, NASA, and even WordPress.com.
Read more in our web server showdown: NGINX vs Apache.
Your Host’s Network Matters
When choosing a WordPress host you might not even think to ask or research into what network they’re using, but you should. The network can have a huge impact on your site’s performance and even the snappiness of your WordPress dashboard. Many hosts will leave this out of their marketing as they’ll opt for the cheapest network to cut costs.
Here are a few questions you should be asking:
- Which networks are you transmitting data over? Is the majority of it over public ISP networks or private infrastructures such as Google or Microsoft? These big providers have networks which are built and optimized for low latency and speed. They even have their own internet cables under the ocean!
- Are the networks you’re using redundant? What happens if a cable is accidentally cut? This happens more often than you think.
Back in 2017 Google announced its standard tier network, which is a slower network but at a cheaper cost. At Kinsta we utilize the premium tier network for all of our hosting plans. While this is an extra cost for us, it ensures you get lightning-fast speeds.
According to Google, the premium tier network achieves improved networking performance by reducing the duration of travel on the public internet; packets enter (and leave) Google’s network as close to the user as possible and then travel on Google’s backbone before getting to the VM. The standard tier delivers outbound traffic from GCP to the internet over public transit (ISP) networks instead of Google’s network.
To put it another way that might be easier to understand:
- Premium tier packets spend more time on Google’s network, with less bouncing around, and thus perform better (but cost more).
- Standard tier packets spend less time on Google’s network, and more time playing hot potato on public networks, and thus, perform worse (but cost less).
How much of an impact does this have? Well, for data traveling across continents, the premium tier network is about 41% faster, on average, than the standard tier network. For data traveling to a nearby region (same continent), the premium tier is about 8% faster. While networking only makes up a fraction of your total page load times, every millisecond adds up!
Redundancy is also key, and that’s why Google uses at least three independent paths (N+2 redundancy) between any two locations on the Google network, helping ensure that traffic continues to flow between the locations even in the event of a disruption.
As you can probably tell by now, a lot is going on behind the scenes when it comes to networking. Make sure your WordPress host is using a reputable one and aren’t opting for the lower tiers to cut costs.
HTTP/2 is a Must-Have
HTTP/2 is a web protocol released in 2015 which was designed to speed up how websites are delivered. Because of browser support, it requires HTTPS (SSL). If your WordPress host doesn’t support HTTP/2 you should start looking for a new provider. With the move of the entire web to HTTPS, this is no longer just a nice feature to have; it’s a necessity.
The improvement in performance with HTTP/2 is due to a variety of reasons such as support better multiplexing, parallelism, HPACK compression with Huffman encoding, the ALPN extension, and server push. There used to be quite a bit of TLS overhead when it came to running over HTTPS, but this is now a lot less thanks to HTTP/2 and TLS 1.3. Kinsta supports HTTP/2 and TLS 1.3 on all of our servers and CDN.
Another big win with HTTP/2 is that with most WordPress sites you no longer need to worry about concatentation (combining files) or domain sharding. These are now obsolete optimizations.
Choose a Server Closest to Your Visitors
One of the very first things you should do when hosting your WordPress site is to determine where the majority of your visitors or customers are coming from. Why is this important? Because the location at which you host your website plays a significant factor in determining your overall network latency and TTFB. It also impacts your SFTP speeds and WordPress admin dashboard responsiveness.
Network Latency: This refers to the time and or delay that is involved in the transmission of data over a network. In other words, how long it takes for a packet of data to go from one point to another. Nowadays this is typically measured in milliseconds; however, it could be seconds depending upon the network. The closer to zero the better.
Check out our in-depth post on network latency.
TTFB: This stands for time to first byte. To put it simply, this is a measurement of how long the browser has to wait before receiving its first byte of data from the server. The longer it takes to get that data, the longer it takes to display your page. Again, the closer to zero the better.
Check out our in-depth post on TTFB.
We won’t bore you with all the technical details in this post, all you need to know is that you want your network latency and TTFB to be as low as possible. One of the easiest ways to accomplish this is to choose a server closest to your visitors. You can determine the best location by following the tips below.
Tip 1 – Check the Geolocation of Your Visitors in Google Analytics
One of the very first things you can do is look at the geolocation of your visitors in Google Analytics. You can find this under “Audience → Geo → Location.”
In this example below, you can see that over 90% of the traffic is coming from the United States. So in most cases, you would want to place your WordPress site on a server in the United States. You could also filter down the data even further to cities. This is especially important if you’re a local company. But typically we would recommend a central location like Iowa, USA.
Tip 2 – Check Ecommerce Data
If you run an eCommerce store, make sure also to check to see where your customers are coming from. This is of course how you generate revenue, so these are your most important visitors. This should coincide with your traffic above; however, this is not always the case. If you have eCommerce data setup or goals in Google Analytics, you can easily overlay that information on top of the geolocation data to make a more informed decision. Or check location information stored in your eCommerce platform’s database.
Tip 3 – Do a Quick Latency Test
There are a lot of handy free tools out there to measure latency from your current location for different cloud providers. This can help you quickly evaluate which region might be the best choice for your site.
- GCP Ping (measure latency to Google Cloud Platform regions, including Kinsta servers)
- CloudPing.info (measure latency to Amazon Web Services regions)
- Azure Latency Test (measure latency to Azure regions)
In this example below, we can see that the Oregon, USA (us-west1) is the fastest from where we are located. However, if you are serving customers across the entire United States, it might be better to choose Iowa, USA (us-central1) to ensure low latency for visitors from both the west and east coast.
Here at Kinsta, we offer 22 different data centers across the globe. You can easily choose a site that will have both low latency and low TTFB! This also helps to reduce network hops.
Additional Ways to Reduce Latency and TTFB
Beyond choose a close server location, here are a few other ways to reduce latency.
- Implement caching on your WordPress site. In our tests caching reduced our TTFB by a whopping 90%!
- Utilize a content delivery network (CDN) to serve cached assets from POPs around the globe. This helps negate the network latency for visitors who might not be close to your host server.
- Take advantage of the HTTP/2 protocol to minimize the number of round trips, thanks to parallelization. HTTP/2 is enabled on all Kinsta servers.
- Reduce the number of external HTTP requests. Each of these can have their own added latency based on the location of their server.
- DNS plays a part in TTFB, so you should use a premium DNS provider with fast lookup times.
- Utilize prefetch and prerender to perform tasks behind the scenes while the page loads.
Don’t worry; we’ll cover all of the recommendations mentioned above further below in this post.
SFTP Speeds and WordPress Admin Dashboard
Your visitors and customers should always be your priority. But another aspect of performance that many don’t talk about is how some of these decisions affect your day to day work. The data center location you choose has an impact on how fast your SFTP download and upload speeds (transferring files with an FTP client) are, as well as the responsiveness of your WordPress admin dashboard.
So while you want to make sure and choose a location that is best for your visitors, also keep in mind that it can affect site management. Tasks like uploading files to the WordPress media library will be faster when your site is hosted on a data center closer to you.
We consistently hear from clients at Kinsta that they are surprised by how much faster their admin dashboard is with us. There is a multitude of factors that influence this, but having 22 different data centers is a big one! Pick a location that works both for your visitors and for you! After all, you’re the one that’s probably going to be spending thousands of hours working on your website.
Premium DNS is Better Than Free DNS
DNS, short for Domain Name System, is one of the most common yet misunderstood components of the web landscape. To put it simply, DNS helps direct traffic on the Internet by connecting domain names with actual web servers. Essentially, it takes a human-friendly request – a domain name like kinsta.com – and translates it into a computer-friendly server IP address – like 216.58.217.206.
You can find both free DNS and premium DNS. All Kinsta customers get access to premium DNS via Amazon Route 53. And in general, we believe that premium DNS is a necessity in today’s world.
One big reason for choosing premium DNS is speed and reliability. Looking up DNS records and directing traffic takes time, even if it’s just a matter of milliseconds.
Typically, the free DNS that you’ll get from your domain name registrar is comparatively slow, whereas premium DNS often offers better performance. For example, in our tests, we found the free NameCheap DNS to be 33% slower than Amazon Route 53 premium DNS. Additionally, premium DNS can offer better security and availability, especially when you’re under a DDoS attack.
You can use a tool like SolveDNS speed test to check your DNS lookup times. DNSPerf also provides excellent performance data on all the tops DNS providers.
For a good middle-ground between the free DNS provided by your domain registrar and premium DNS, Cloudflare DNS is a free service that still offers many of the benefits of premium DNS. And they are blazing fast with under 20 ms average response times around the globe (as seen below).
However, one caveat with Cloudflare is that it also has more downtime than a lot of other providers. If you’re primarily serving visitors in the United States, DNS Made Easy is another great premium DNS provider you might want to check out. They have a reputation for providing some of the best DNS uptime over the past decade.
In the last 30 days, DNSPerf shows the following uptime from these providers:
- DNS Made Easy: 99.99% which equals 4m 23.0s monthly downtime.
- Amazon Route 53: 99.88% which equals 52m 35.7s monthly downtime.
- Cloudflare: 99.85% which equals 1h 5m 44.6s monthly downtime.
Does downtime matter that much with DNS providers? The answer to this is really yes and no. DNS is typically cached with ISPs using the time to live value (TTL) on the DNS record. Therefore if a DNS provider goes down for 10 minutes, you’re most likely not going to notice anything. Downtime does matter though if the provider consistently has longer and frequent outages, or if your ISP and DNS records both are using really low TTL values.
Your WordPress Theme Matters
Everybody loves a brand new WordPress theme, but be careful before you go out and grab the one with all the new shiny features. First, you should check out our article on the differences when it comes to free vs. paid themes. In regards to performance, every element you see in a theme has some impact on the overall speed of your website. And unfortunately, with thousands of themes out in the wild, there are both good ones and bad ones.
So how are you supposed to know which one to choose? We recommend going with one of the following two options:
- A fast lightweight WordPress theme that is built with only the features you need, nothing more.
- A more feature-rich WordPress theme, but you can disable features that aren’t in use.
Things such as Google Fonts, Font Awesome icons, sliders, galleries, video and parallax scripts, etc. These are just a few of the many things that you should be able to turn off if you aren’t using them. You don’t want to be trying to tweak these manually after the fact. And we aren’t going to show you 50 different ways to strip things out. Instead, you should start or switch to a WordPress theme that is either lightweight from the beginning or gives you these options.
Below are a couple of WordPress themes that we recommend and that you can’t go wrong with! Trust us, you’ll be thanking us later. 😉
Every theme mentioned below is fully compatible with WooCommerce and Easy Digital Downloads, WPML, BuddyPress, and bbPress. We run a few speed tests with each theme using the following configuration:
- Hosted on Kinsta, running WordPress 4.9.8
- PHP 7.3 and SSL (HTTPS)
- Kinsta CDN
- Imagify was used to automatically compress images.
GeneratePress
GeneratePress is a fast, lightweight (less than 1MB zipped), mobile responsive WordPress theme built with speed, SEO and usability in mind. Built by Tom Usborne, a developer from Canada. It is actively updated and well supported. Even a few Kinsta team members use GeneratePress for their projects.
There is both a free and premium version available. If you take a look at the WordPress repository, the free version currently has over 200,000 active installs, 2+ million downloads, and an impressive 5 out of 5-star rating (over 850 people have given it 5 stars).
One of the great things about GeneratePress is that all the options use the native WordPress Customizer, meaning you can see every change you make instantly before pressing the publish button. This also means you don’t have to learn a new theme control panel.
Just how fast is it? We did a fresh install of GeneratePress, ran five speed tests in Pingdom, and took the average. The total load time was 305 ms with a total page size of only 16.8 KB. It’s always good to have a baseline test to see what the theme is capable of in terms of raw performance.
We then ran another set of tests with one of the pre-built themes from the GeneratePress site library. This contains images, backgrounds, new sections, etc. One advantage GeneratePress has is that it has a lot of pre-built themes that don’t require a page builder plugin. You can see that it’s still clocked under 400 ms.
Now of course, in a real-world environment you might have other things running such as Google Analytics, Facebook remarketing pixel, Hotjar, etc. But you should be able to aim for under the 1-second mark easily. Check out an in-depth review of GeneratePress over on woorkup.
We’ll be showing you more ways you can optimize and speed up WordPress below.
OceanWP
The OceanWP theme is lightweight and highly extendable. It enables you to create almost any type of website, such as a blog, portfolio, business website or WooCommerce storefront with a beautiful & professional design. Built by Nicolas Lecocq, it is also actively updated and well supported.
Just like with GeneratePress, there is both a free and premium version available. If you take a look at the WordPress repository, the free version currently has over 400,000 active installs, and another impressive 5 out of 5-star rating (over 2,600 people have given it 5 stars).
Just how fast is it? We did a fresh install of OceanWP, ran five speed tests in Pingdom, and took the average. The total load time was 389 ms with a total page size of only 230.8 KB. The scripts in OceanWP are slightly larger, but nothing to write home about.
We then ran another set of tests with one of the demo themes from the OceanWP site library. This contains images, backgrounds, new sections, and required the Elementor page builder plugin. You can see that it’s still clocked under 600 ms.
You can check out a more in-depth review of OceanWP on our blog.
Astra
Astra is a fast, fully customizable & beautiful theme suitable for blogs, personal portfolios, business websites, and WooCommerce storefronts. It is very lightweight (less than 50 KB on frontend) and offers unparalleled speed. Built by the team at Brainstorm Force, it is actively updated and well supported. You might recognize them as the creators of the popular All In One Schema Rich Snippets plugin which has been around for many years.
Just like with GeneratePress and OceanWP, there is both a free and premium version available. If you take a look at the WordPress repository, the free version currently has over 400,000 active installs, 1.6+ million downloads, and another impressive 5 out of 5-star rating (over 2,500 people have given it 5 stars).
Just how fast is it? We did a fresh install of Astra, ran five speed tests in Pingdom, and took the average. The total load time was 243 ms with a total page size of only 26.6 KB.
We then ran another set of tests with one of the demo themes from the Astra Starter kit site library. This contains images, backgrounds, new sections, and required the Elementor page builder plugin. You can see that it’s still clocked under 700 ms. Note: the images in this demo were fully compressed, but they chose very high-resolution ones from the start.
It’s important to take the differences between the speed tests with these three themes with a grain of salt. The problem is that it’s almost impossible to run a completely accurate side by side comparison. The important thing we wanted to show you is that all of these WordPress themes are blazing fast, both out of the box and full demos! 🚀
Warning About Page Builders
As you probably noticed, OceanWP and Astra both required page builders to use their site library themes. Here are a few things to keep in mind when using a page builder plugin:
- Some page builders might increase load time on your site. This is because they have to load additional CSS and JS to make things work for you without code. That is how the magic happens! We always recommend speed testing your WordPress site before and after installing a page builder.
- You’re making committing and locking yourself into that page builder for design. Make sure you pick one that is regularly updated and has everything you need for the long haul.
With that being said, we are still big fans of page builders like Elementor and Beaver Builder. For the most part, they are developed with performance in mind and only add a little bit of overhead. For most, the functionality and usability are worth it, as these plugins allow you to create anything you can dream up! They might also be faster in some cases as they might be a replacement for 5+ other plugins that you would have had to use otherwise.
However, if you don’t need a page builder plugin, by all means, don’t just install one for kicks. It will also be interesting to see how the new Gutenberg editor will play a role in site design over the next couple of years.
The Lowdown on WordPress Plugins
Now for the scoop on WordPress plugins. You might have been told that you shouldn’t install too many plugins or it would slow down your WordPress site. While this is sometimes true, it’s not the most critical factor. The number of plugins isn’t as important as the quality of the plugins. There, we said it. 😜
Just like with themes, it matters how the plugin is developed and if it was built with performance in mind. We have many clients at Kinsta that are running 30-40 plugins and their sites still load in well under a second.
While it’s fun to add code to your site, this isn’t always practical for the following reasons:
- You have to maintain the code yourself and keep it updated as standards change. People are busy, why not rely on the fantastic developers who know the standards better than most?
- Most of the time, a well-coded plugin isn’t going to introduce much more overhead than the code itself.
- You have to remember a majority of the WordPress community isn’t as tech-savvy as the developer crowd. Plugins are solutions that help solve problems.
With that being said, there are of course not so great plugins out there which you want to stay away from. Trust us; we’ve seen the worst of the worst at Kinsta. Many, not all, of the plugins that we ban at Kinsta we’ve seen cause performance issues first-hand.
Francesco has an interesting post in which he dives into load testing WordPress plugins to see how they perform on a WordPress site’s back-end, which in most cases, is not cached. We’ll dive into how to find bad plugins on your site further below.
However, it can’t be ignored that one of the things people love about WordPress is its massive library of third-party plugins. But with 56,000+ free plugins listed at WordPress.org alone and thousands more listed elsewhere, it can be hard to find the one plugin that you need. Talk about a needle in a haystack! Check out the list we’ve compiled of only the best WordPress plugins on the market.
We try only to share things we use on a daily basis. And yes, we use WordPress plugins on our site just like the rest of you. Many of the team members at Kinsta even develop and sell plugins.
One Big Issue with WordPress Plugins
One big issue with WordPress plugins is the uninstall process. Whenever you install a WordPress plugin or theme, it stores the data in the database. The problem is that when you delete a plugin using one of the standard methods, it typically leaves behind tables and rows in your database. Over time this can add up to a lot of data and even begin to slow your site down. In our example, we uninstalled the Wordfence security plugin, and it left behind 24 tables in our database (as seen below). It’s even worse if they’re behind data in your wp_options
table.
And besides the database, a lot of plugins also leave behind additional folders and files. In our experience, this is commonly seen with security and caching plugins which create additional directories for logging. For example, after the Wordfence plugin was deleted, we were left with a “wflogs” folder in our wp-content directory. And we aren’t trying to pick on Wordfence, the majority of plugins and themes on the market work this way.
Why Do Developers Do This?
So you are probably wondering, why don’t developers have self-cleanup options when you uninstall and delete a plugin? Well, they do. But, here are a couple of reasons why they probably aren’t as obvious right off the bat.
- They want to retain settings for the user. If you delete a WordPress plugin and decide to try it again later, all your settings and data will still be there. While this is super convenient, it’s not the most efficient way.
- They don’t care about performance. Some developers might argue that leaving tables behind doesn’t impact performance. But imagine a site over the course of ten years, having used hundreds of plugins, that have generated possibly thousands of rows or tables. Database queries have a significant impact on your WordPress site’s performance, and plugins can make a lot of these requests if the developer wasn’t careful. Generally, a well-written plugin should only query the tables or rows in which it is tied to, however, this is not always the case. We’ve seen this first hand at Kinsta, long database queries bringing a site to crawl due to unnecessary autoloaded data in the wp_options table which has been left behind.
- They made a mistake. The WordPress plugin handbook even says that “less experienced developers sometimes make the mistake of using the deactivation hook for this purpose.”
The good news? There are ways to clean up and get rid of a plugin properly. 👏 Check out our following tutorials:
Optimal WordPress Settings
Now to move on to optimal WordPress settings. Here are a couple of changes you can make to help speed up your WordPress site. Many of these are very subtle changes, but everything helps!
Change Your WordPress Login URL
By default your WordPress site’s login URL is domain.com/wp-admin/
. One of the problems with this is that all of the bots, hackers, and scripts out there also know this. By changing the URL, you can make yourself less of a target, better protect yourself against brute force attacks, and decrease the bandwidth used by the bots that hit this URL repeatedly.
Changing your WordPress login URL can also help prevent common errors like “429 Too Many Requests.” This is not a fix-all solution, it’s merely one little trick that can help protect you and decrease the load on that page.
To change your WordPress login URL we recommend using one of the following plugins:
- WPS Hide Login (free)
- Perfmatters (premium, but includes other performance optimization settings. Developed by a team member at Kinsta)
Disable or Tweak Plugin and Theme Updates
Slow WordPress admin dashboards can be impacted by the network, data center location, and even PHP versions. But another factor that not a lot of people talk about is the WordPress update checker that runs in the background. This is one instance where having a lot of WordPress plugins and themes could hurt you. WeFoster has a great blog post about this where they coin the phrase the “Third Party Plugin Update Check Syndrome” or TPPUCS.
Essentially the problem is that the built-in WordPress update checker makes an external GET request behind the scenes (https://third-party-plugin/update-check.php
). Sometimes this can be periodic or very frequently. If it’s happening all the time, this could bring your admin dashboard to a crawl.
This is more of a problem with how the update checker in WordPress is built. If you’re suffering from slow WordPress admin dashboard load times, you might want to give this a try. The remedy is to disable automatic updates. Warning: Only do this if you intend to check for updates manually. Many updates include security and bug fixes.
To disable updates, we recommend using one of the following plugins:
- Disable All WordPress Updates: Completely free with no settings. Does what it says well.
- Easy Updates Manager: Provides more control over selective updates. The core version is free.
You could easily set yourself a calendar reminder, disable the plugin once a week, check for updates, and then re-enable it.
Disable Pingbacks
A pingback is an automated comment that gets created when another blog links to you. There can also be self-pingbacks which are created when you link to an article within your own blog.
We recommend simply disabling these as they generate worthless queries and additional spam on your site. Remember, the less calls your WordPress site has to make the better, especially on high-traffic sites. Not to mention the fact that a pingback on your own website is just downright annoying. Follow the steps below to disable pingbacks.
Step 1 – Disable Pingbacks From Other Blogs
In your WordPress dashboard, click into “Settings → Discussion.” Under the Discussion Settings section uncheck the option “Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.”
Step 2 – Disable Self-Pingbacks
When it comes to disabling self-pingbacks you have a couple of options. You can use the free No Self Pings plugin. Or you can use a premium plugin like Perfmatters.
Alternatively, you could also disable self-pingbacks by adding the following code to your WordPress theme’s functions.php
file. Warning, editing the source of a WordPress theme could break your site if not done correctly. Tip, you can easily add PHP snippets like this with the free Code Snippets plugin. This means you never have to touch your theme.
function wpsites_disable_self_pingbacks( &$links ) {
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, get_option( 'home' ) ) )
unset($links[$l]);
}
add_action( 'pre_ping', 'wpsites_disable_self_pingbacks' );
Limit Posts on Your Blog Feed
Whether your blog feed is set as your homepage or is another page of your site, you don’t need 50 thumbnails all loading at the same time. For those that run high-traffic blogs, your homepage is the most important page of your site, and you want this to load fast. The fewer requests and media the better in terms of performance.
Also, this is precisely why pagination was invented (as seen below). Pagination is what you see at the end of blog feeds that allow you to browse to the next page. Typically these are numbers, or they might use “next/previous” posts. Your WordPress theme will most likely already have customized pagination built-in.
WordPress by default sets the limit on fresh WordPress installations to 10, but we’ve seen this changed so many times we’ve lost count. So make sure to double-check what value you’re using. We recommend somewhere between 8 and 12. If you’re curious, we are using 12 on our Kinsta blog homepage.
You can find this option in your WordPress admin dashboard under “Settings → Reading.” You can then change the value for “Blog pages show at most.”
Why Cache Is so Important
Caching is by far one of the most important and easiest ways to speed up WordPress! But before we show you how to use caching, it’s essential first to understand how it works and the different kinds of caching available.
What is Caching?
In short, every webpage visited on your WordPress site requires a request to the server, processing by that server (including database queries), and then a final result sent from the server to the user’s browser. The result is your website, complete with all of the files and elements that make it look the way it does.
For instance, you might have a header, images, a menu, and a blog. Since the server has to process all of those requests, it takes some time for the complete webpage to be delivered to the user–especially with clunky or larger websites.
That’s where a WordPress caching plugin comes into play! Caching instructs the server to store some files to disk or RAM, depending on the configuration. Therefore, it can remember and duplicate the same content it’s been serving in the past. Basically, it reduces the amount of work required to generate a page view. As a result, your web pages load much faster, directly from cache.
Some other benefits of caching include:
- Your server uses fewer resources – This ties into speed, since the fewer resources make for a faster site. However, it also puts less of a strain on your server. This is very important when it comes to highly dynamic sites, such as membership sites, and determining what you can and cannot serve from cache.
- You’ll see lower TTFB – Caching is one of the easiest ways to lower your TTFB. In fact, in our tests caching typically reduces TTFB by up to 90%!
Types of Caching
When it comes to types of caching, there are two different approaches commonly used:
1. Caching at the Server-Level
Caching at the server-level is by far one of the easiest approaches for the end-user. What this means is that the WordPress hosting provider handles it for you. At Kinsta, we utilize the following four types of cache, which are all automatically done at the software or server-level:
This means you don’t need to worry about messing with any complicated and confusing caching plugins. You can stop Googling around for the “best caching plugins of 2020” and focus on more productive tasks. 👏
The page cache is configured to work right out of the box with standard WordPress. You don’t have to do a thing! Simply launch your WordPress site and page caching will start happening.
We also have caching rules in place for ecommerce sites such as WooCommerce and Easy Digital Downloads. By default, certain pages that should never be cached, such as cart, my-account, and checkout, are excluded from caching. Users automatically bypass the cache when the woocommerce_items_in_cart
cookie or edd_items_in_cart
are detected to ensure a smooth and in-sync checkout process.
You can easily clear your WordPress site’s cache at any time from the admin toolbar.
It’s also integrated into our MyKinsta dashboard. Just click into Tools and click on “Clear Cache.”
2. Caching with a Plugin
If you’re hosting provider doesn’t provide cache, you can use a third-party WordPress caching plugin. Based on our experience, we recommend one of the following:
- WP Rocket (premium)
- Cache Enabler (free)
- W3 Total Cache (free)
You can also check out some additional options in our in-depth post on WordPress caching plugins.
We also fully support WP Rocket at Kinsta! We usually don’t allow caching plugins in our environment because they conflict with our built-in caching solution. However, as of WP Rocket 3.0, their page caching functionality will automatically be disabled when running on Kinsta servers.
This allows Kinsta clients to use our fast server-level caching but still take advantage of the fantastic optimization features WP Rocket has to offer.
No Caching vs Caching
How much does caching help? The proof is in the pudding.
We ran a few speed tests with Kinsta’s server-level caching so you can see the difference it makes, both in terms of overall speed and TTFB.
No Caching
We first ran five tests on Pingdom without caching enabled and took the average.
No Caching TTFB
It’s also important to note the difference in TTFB without and with caching. TTFB in Pingdom is represented by the yellow “waiting” bar. As you can see the TTFB with no caching is 192 ms. You can see that it’s not serving from cache as the x-kinsta-cache
header is showing a MISS.
With Caching Enabled
We then enabled server-level caching and ran five tests on Pingdom and took the average.
As you can see server-level caching decreased our page load time by 33.77%! And that’s without any extra work involved. This site we tested is also fairly optimized, so larger unoptimized sites are bound to see even greater differences.
TTFB with Caching Enabled
Now if we take a look at the TTFB with caching enabled, we can see that it’s under 35 ms. You can see that it’s serving from cache as the x-kinsta-cache
header is showing a HIT.
CDN cache is also equally as important as cache from your WordPress host. We’ll dive more into CDNs further below.
Issues with Caching and Membership Sites
Membership sites contain a lot of uncacheable content and pages that are continuously changing. Things such as the login page for community members (which could be getting hit constantly depending on the size of the site), checkout pages for digital goods or courses, and discussion boards are common culprits and pain points, as these cannot typically be cached.
However, it doesn’t end there. On standard WordPress sites, the WordPress dashboard is also not cached for “logged-in” users. This is fine when you have just a few authors and admins, but when you suddenly have thousands of members using the dashboard, this immediately causes performance issues as none of it can serve from the cache on the server. This means you need the power and architecture behind the scenes to back it up. Shared hosting providers will usually cripple under these circumstances.
Object Caching for Highly Dynamic Sites
When it comes to WordPress membership sites, your common caching setups are usually not enough as they don’t always take full advantage of it. This is where object caching comes into play.
Object cache stores the results of database queries so that the next time that particular bit of data is needed it can be delivered from cache without querying the database. This speeds up PHP execution times and reduces the load on your database. This becomes extremely important with membership sites! With WordPress, you can implement object caching in a couple of different ways:
- A third-party caching solution such as W3 Total Cache
- Redis (recommended)
- Memcached
We offer Redis as an add-on at Kinsta so you can take full advantage of persistent object caching for your membership sites.
Analyzing Cache
Remember that x-kinsta-cache
header we mentioned above? Depending on your hosting provider or caching solution the header might be named something slightly different. Every time a request is made from your WordPress site that header has a value, such as HIT, BYPASS, MISS, and EXPIRED. This allows you to see how your cache is performing.
Increasing your WordPress site’s cache hit ratio is important because you want as much of your site to be served from cache as possible. At Kinsta you can analyze the data in our MyKinsta analytics tool and the kinsta cache logs to determine if there are cache BYPASSing GET requests that could be cached or POST requests that could be eliminated.
The cache component stack (as shown below) lets you see the status of each request, whether it was a HIT, BYPASS, MISS, or EXPIRED. You can filter the data by the past 24 hours, 7 days, or 30 days.
The cache component chart gives you a glance at your caching ratio. The more requests you serve from cache the better. As you can see in the example below, this WordPress site is at a 96.2% HIT cache ratio. Which is good!
The top cache bypasses section lets you see which requests are not being served from cache. Typically these might include CRON jobs, admin-ajax requests, ecommerce checkout pages, query strings, and UTM parameters, etc.
Image Optimization Is a Must
Image optimization is another straightforward thing you can do which has a significant impact on your overall page load times. This isn’t optional; every site should be doing this!
Large images slow down your web pages which creates a less than optimal user experience. Optimizing images is the process of decreasing their file size, using either a plugin or script, which in turn speeds up the load time of the page. Lossy and lossless compression are two methods commonly used.
According to HTTP Archive, as of August 2019, images make up on average of 34% of a total webpage’s weight. So after videos, which are much harder to optimize, images by far are the first place you should start! It’s more important than JavaScript, CSS, and Fonts. And ironically, a good image optimization workflow is one of the easiest things to implement, yet a lot of website owners overlook this.
Images made up on average 54% of a pages’ overall weight back in December 2017. So it appears the web as a whole is getting better at image optimization! But 34% is still a number that can’t be ignored. If you don’t have any video content on your website, images are still probably your #1 pain point for page weight.
Finding the Balance (File Size and Quality)
The primary goal of formatting your images is to find the balance between the lowest file size and acceptable quality. There is more than one way to perform almost all of these optimizations. One of the most basic ways is to compress them before uploading to WordPress. Usually, this can be done in a tool like Adobe Photoshop or Affinity Photo. Or using the new online Squoosh app from Google. However, these tasks can also be performed automatically using plugins, which we will go into more below.
The two primary things to consider are the file format and the type of compression you use. By choosing the right combination of file format and compression type you can reduce your image size by as much as 5 times. You’ll have to experiment with each image or file format to see what works best.
Before you start modifying your images, make sure you’ve chosen the best file type. There are several types of files you can use:
- PNG – produces higher quality images, but also has a larger file size. Was created as a lossless image format, although it can also be lossy.
- JPEG – uses lossy and lossless optimization. You can adjust the quality level for a good balance of quality and file size.
Ideally, you should use JPEG (or JPG) for images with lots of color and PNG for simple images.
What about GIFs? Animated GIFs are always fun, but they kill web performance. A lot of GIFs are over 1 MB in size. We recommend keeping these for social media and Slack. If there is one that you can’t live without in your blog post, take a look at how you can compress animated GIFs.
Compression Quality vs. Size
Here is an example of what can happen you compress an image too much. The first is using a very low compression rate, which results in the highest quality (but larger file size). The second is using a very high compression rate, which results in a very low-quality image (but smaller file size). Note: The original image untouched is 2.06 MB.
As you can see the first image above is 590 KB. That is pretty large for one photo! It is generally best if you can keep a webpage’s total weight under 1 or 2 MB in size. 590 KB would be a fourth of that already. The second image looks horrible, but then it is only 68 KB. What you want to do is find a happy medium between your compression rate (quality) and the file size.
So we took the image again at a medium compression rate, and as you can see below, the quality looks good now, and the file size is 151 KB, which is acceptable for a high-resolution photo. This is almost 4x smaller than the original photo with low compression. We try to keep most of our images under the 100 KB mark for the best performance.
Lossy vs. Lossless Optimization
It’s also important to understand that there are two types of compression you can use, lossy and lossless.
Lossy compression involves eliminating some of the data in your image. Because of this, it means you might see degradation (reduction in quality or what some refer to as pixelated). So you have to be careful by how much you’re reducing your image. Not only due to quality, but also because you can’t reverse the process. Of course, one of the great benefits of lossy compression and why it’s one of the most popular compression methods is that you can reduce the file size by a considerable amount.
Lossless compression, unlike lossy, doesn’t reduce the quality of the image. How is this possible? It’s usually done by removing unnecessary metadata (automatically generated data produced by the device capturing the image). However, the biggest drawback to this method is that you won’t see a significant reduction in file size. In other words, it will take up a lot of disk space over time.
You will want to experiment with what works best for you. But for the majority of users, we recommend using lossy compression due to the fact that you can easily compress an image well over 70% (sometimes even over 90%!) without much quality loss. Multiply this by 15 images on a page, and it will play a significant role in reducing your site’s load time.
Image Compression Plugins
The great news is that there are some amazing WordPress image compression plugins you can use to automate the entire process. Here are some plugins we recommend:
- Imagify (lossy and lossless – optimizes images externally)
- WP Smush (lossy and lossless – optimizes images externally)
- Optimole (lossy and lossless – optimizes images externally)
- EWWW Cloud (lossy and lossless – optimizes images externally)
- ShortPixel (lossy and lossless – optimizes images externally)
The most important thing when choosing an image optimization plugin is to use one that it compresses and optimizes images externally on their servers. This, in turn, reduces the load on your site. All of the ones above do this.
If you’re curious, we use the Imagify plugin on the Kinsta website. It automatically compresses images when we upload them to the WordPress media library. So we never have to worry about a thing. Over time you can get a feel for what image compression level you want to use. It offers Normal, Aggressive, and Ultra.
We use the Aggressive mode at Kinsta and typically see 60-70% savings depending on the image. Note: we use a lot more PNGs than JPEGs due to the fact that most of our images are icons and illustrations, not photos.
How much faster will your WordPress site be if you use image compression? It all depends on the sizes of your original images and what they are after compression. However, we ran some speed tests and found that a quality image compression solution can decrease page load times by over 80%!
Lazy Loading
If you have a lot of images, you might consider lazy loading them. This is an optimization technique that loads visible content but delays the downloading and rendering of content that appears below the fold.
Check out our guide on how to implement lazy loading in WordPress. This can be especially important on blog posts with lots of gravatar icons from comments. Google also just released their recommendations for lazy loading.
Additional Image Optimization Tips
Here are a few final image optimization tips to walk away with.
- The days of uploading images only sized to the width of the column or DIV are over. Responsive images work out of the box in WordPress (since version 4.4) and will automatically display smaller image sizes to mobile users.
- SVGs can be another awesome alternative to using images. All of the hand-drawn illustrations you see around the Kinsta website are SVGs (vectors). SVGs are typically a lot smaller in file size, although not always. Check out our tutorial on how to use SVGs on your WordPress site.
- Use icon fonts instead of placing text within images – they look better when scaled and take less space. And if you use a font generator, you can optimize them even more. Check out how we decreased the size of our icon fonts file by a whopping 97.59% using a font generator.
Fine-Tune Your Database
Next up are some tips on how to fine-tune your WordPress database. Just like a car your database needs upkeep as over time it can become bloated.
Membership sites especially make it tricky, as they usually generate more complex queries, which in turn adds additional latency in retrieving the information from the MySQL database. A lot of this is due to all the additional moving parts and large amounts of data sites like these have. This might also be caused by sites that heavily rely on search queries for navigation or use WP_Query
.
Not to mention, you also have large amounts of concurrent users continuously querying the database.
Use the InnoDB MySQL Storage Engine
A lot of older sites are still using the MyISAM storage engine in their database. Over recent years, InnoDB has shown to perform better and be more reliable.
Here are a couple of advantages of InnoDB over MyISAM:
- InnoDB has row-level locking. MyISAM only has full table-level locking. This allows your queries to process faster.
- InnoDB has what is called referential integrity which involves supporting foreign keys (RDBMS) and relationship constraints, MyISAM does not (DMBS).
- InnoDB supports transactions, which means you can commit and roll back. MyISAM does not.
- InnoDB is more reliable as it uses transactional logs for auto recovery. MyISAM does not.
So now you might be wondering, are you running InnoDB or MyISAM? If you are running on a fairly new WordPress site chances are you are already using the InnoDB MySQL storage engine. But with older WordPress sites you might want to do a quick check. Some sites might even have mixed and matched MyISAM and InnoDB tables, in which you could see improvements by converting them all over.
Follow these simple steps below to check.
Step 1
Login to phpMyAdmin and click on your MySQL database.
Step 2
Do a quick scan or sort of the “Type” column, and you can see which Storage Engine types your tables are using. In this example below, you can see that two of the tables are still using MyISAM.
Delete and Limit Page and Post Revisions
Whenever you save a page or post in WordPress, it creates what is called a revision. This occurs in both drafts and already published posts that are updated. Revisions can be helpful in case you need to revert to a previous version of your content.
However, revisions can also hurt the performance of your WordPress site. On large sites, this can add up very quickly to thousands of rows in your database which are not necessarily needed. And the more rows you have, the larger your database in size, which takes up storage space. While indexes were created for this very purpose, we’ve still seen this issue cripple WordPress sites. There are a couple of things you can do.
1. Delete Old Revisions
If you have an older WordPress site with a lot of pages and posts, it might be time to do a quick cleanup and delete those old revisions. You can do this with MySQL, but with all the bad snippets of code floating around the web, we recommend doing a backup of your site and using a free plugin like WP-Sweep.
Another one of our favorite plugins, WP Rocket, also has a database optimization feature to clear out revisions.
If you’re handy with WP-CLI, there’s a couple of commands you can use for this.
Login to your server via SSH and run the following command to get and see the number of revisions currently in the database.
wp revisions list
If you get an error, you might need to first install the wp-revisions-cli package with the following command:
wp package install trepmal/wp-revisions-cli
You can then run the following command to clean up the revisions:
wp revisions clean
2. Limit Revisions
Another good strategy and one that we use at Kinsta is to limit the number of revisions that can be stored per post or page. Even setting it to something like ten will keep revisions from getting out of hand, especially if you do a lot of updating.
To limit revisions, you can add the following code to your wp-config.php
file. The code below needs to be inserted above the ‘ABSPATH’ otherwise it won’t work. You can change the number to however many revisions you want to keep stored in your database.
define('WP_POST_REVISIONS', 10);
Or you can utilize a plugin like Perfmatters to limit revisions.
3. Disable Revisions
And last but not least, you can also disable revisions on your site altogether. If you’re going this route, we highly recommend following the first option above to delete revisions and then disabling them afterward. This way your database is completely free from all old revisions and no new ones will be added going forward.
To disable revisions, you can add the following code to your wp-config.php
file. The code below needs to be inserted above the ‘ABSPATH’ otherwise it won’t work.
define('WP_POST_REVISIONS', false);
Or you can utilize a plugin like Perfmatters to disable revisions.
Clean up Your wp_options Table and Autoloaded Data
The wp_options
table often gets overlooked when it comes to overall WordPress and database performance. Especially on older and large sites, this can easily be the culprit for slow query times on your site due to autoloaded data that is left behind from third-party plugins and themes. Trust us; we see this every single day!
The wp_options table contains all sorts of data for your WordPress site such as:
- Site URL, home URL, admin email, default category, posts per page, time format, etc
- Settings for plugins, themes, widgets
- Temporarily cached data
This table contains the following fields (columns):
- option_id
- option_name
- option_value
- autoload (this is the one we care about when it comes to performance)
One of the important things to understand about the wp_options
table is the autoload field. This contains a yes or a no value (flag). This essentially controls whether or not it is loaded by the wp_load_alloptions() function. Autoloaded data is data that is loaded on every page of your WordPress site. Just like we showed you how to disable certain scripts from loading sitewide, the same idea applies here. The autoload attribute is set to “yes” by default for developers, but not every plugin should theoretically load their data on every page.
The problem WordPress sites can run into is when there is a large amount of autoloaded data in the wp_options
table. This is typically a result of the following:
- Data is being autoloaded by a plugin when it should be set to “no.” A good example of this would be a contact form plugin. Does it need to load data on every page or just the contact page?
- Plugins or themes have been removed from the WordPress site, but their options are still left behind in the
wp_options
table. This could mean unnecessary autoloaded data is getting queried on each request. - Plugin and theme developers are loading data into the
wp_options
table instead of utilizing their own tables. There are arguments to both sides of this, as some developers prefer plugins that don’t create additional tables. However, thewp_options
table also wasn’t designed to hold thousands of rows.
How much is too much-autoloaded data? This can vary of course, but ideally, you want this to be between 300 KB to 1MB. Once you start approaching the 3-5 MB range or more, there are most likely things that can be optimized or removed from being autoloaded. And anything above 10 MB should be addressed right away. This doesn’t always mean it’s going to cause an issue, but it’s a good place to start.
Because this is such a problem we have a whole separate tutorial you’ll want to read on how to best troubleshoot autoloaded data as well as how to clean it up.
Clean up Transients
Unless you’re using an object cache, WordPress stores transient records in the wp_options
table. Typically these are given an expiration time and should disappear over time. However, that is not always the case. We have seen some databases where there are thousands of old transient records. In fact, in on one site, we dealt with some corrupt transient records in which over 695,000 rows were generated in the wp_options
table. Yikes!
It’s also important to note that transients are not to autoloaded by default. You could use a query like the below to see if there are any autoloaded transient data.
SELECT *
FROM `wp_options`
WHERE `autoload` = 'yes'
AND `option_name` LIKE '%transient%'
A better and safer option would be to utilize a free plugin like Transient Cleaner or Delete Expired Transients which can clean up only the expired transients from your wp_options
table. However, it appears there is now a function in WordPress, added in 4.9, that housekeeps expired transients. So hopefully that is happening automatically on your site now.
WP Rocket also has the ability to cleanup transients in their database optimization options.
Clean up WordPress Sessions
Another common issue we’ve seen is sometimes cron jobs get out of sync or don’t fire properly, and therefore sessions don’t get cleaned up. You can wind up getting tons of _wp_session_
rows in your database. In this example below the site in question wound up with over 3 million rows in their wp_options
table. And the table had grown to over 600 MB in size.
You could use a query like the one below to see if you’re running into this issue:
SELECT *
FROM `wp_options`
WHERE `option_name` LIKE '_wp_session_%'
In most cases you can then safely delete these (as a cron job should have) with the following command:
DELETE FROM `wp_options`
WHERE `option_name` LIKE '_wp_session_%'
After cleaning up all the leftover _wp_session_
rows the table had less than 1,000 rows and was reduced to 11 MB in size.
It also fixed the spikes the site was getting in MySQL.
Add an Index to Autoload
If cleaning up your wp_options
table wasn’t enough, you could try adding an “index” to the autoload field. This essentially can help it to be searched more efficiently. The awesome team over at 10up performed some test scenarios on a wp_options
table with a typical number of autoloaded records to show how adding an autoload index to wp_options
queries can boost performance.
We also recommend checking out these two additional resources from WP Bullet:
Use Redis as a Persistent Object Cache for WordPress
Redis is an open-source, in-memory data structure store. In the context of WordPress, Redis can be used to store the values generated by WordPress’ native object cache persistently so that cached objects can be reused between page loads.
Using a persistent object cache such as Redis allows for the reuse of cached objects rather than requiring the MySQL database to be queried a second time for the same object. The result is that Redis can reduce the load on a website’s MySQL database, simultaneously decreasing the response time of the site and increasing the site’s ability to scale and handle additional traffic.
Highly dynamic websites (WooCommerce, membership sites, forums, discussion boards, blogs with extremely active comment systems) that cannot make good use of page caching are potential candidates for a persistent object caching option such as Redis.
If you’re a Kinsta client, we offer a Redis add-on. Check out how to add Redis to your hosting plan.
Use Elasticsearch to Speed Up WordPress Search
Elasticsearch is an open-source full-text search engine. It is used to index data and search that data incredibly quickly.
In the context of WordPress, Elasticsearch can be used to speed up querying of the WordPress database. This is done by building an index of the content of your site’s database and then using Elasticsearch to search this index much more quickly than a MySQL query is capable of performing the same search.
If you have the time and ability, Elasticsearch can be integrated with a WordPress site by a highly knowledgeable WordPress and Elasticsearch developer. If your site makes relatively standard use of WP_Query, Elasticsearch can also be integrated by installing ElasticPress, a free WordPress plugin from 10up, available from WordPress.org, which automatically integrates with the WP_Query object to generate query results with Elasticsearch rather than MySQL.
Any site that makes heavy use of WP_Query can benefit from Elasticsearch. Examples of sites that can benefit from Elasticsearch:
- Sites where search is the primary means of navigation.
- WooCommerce sites with a huge number of orders where site admins need to be able to search the list of orders regularly.
- Any site with a large number of posts where MySQL queries are producing unacceptably slow results.
Just like with Redis, we also have an Elasticsearch add-on. Check out how to add Elasticsearch to your hosting plan.
Disable Non-Critical Features That Are Database-Intensive
This might seem a little obvious, but it can make a world of difference if you disable non-critical plugins and theme features that are database-intensive.
- Popular and or related post widgets and plugins are horrible. They typically have heavy sitewide queries.
- Image optimization plugins that compress images using your server. You should always use an image optimization plugin that optimizes images externally.
If you visit the Kinsta blog and scroll down to the end of a post, you’ll notice that we have what we call “hand-picked” related articles. These are selected by us manually and assigned to the post. This reduces the query to almost nothing and won’t hurt the performance of your entire site. Does it take more work? Yes, but it can be even better as you can choose what you want readers to see.
So how did we accomplish this? We used the amazing Advanced Custom Fields plugin and then assigned these fields to our blog post type. This allows us to search and assign whatever related content we want to each of our blog posts (as seen below).
We also recommend staying away from plugins that add a view/post counter to your site, unless you absolutely need it. For example, avoid things like “792 posts” next to a user’s avatar in forum posts or “5,243 views” when listing forum posts. When you have a long discussion, these counters will take a huge toll on your database. In general, minimize the use of counters and only use them if necessary.
This also goes for a lot of social counters. For example, on this site below you can see the response time from the popular Social Warfare plugin is 30x more than the next plugin below it. Caching is enabled, but obviously, this plugin has a considerable performance toll. After disabling the plugin on the site, load times instantly improved and the responsiveness of the WordPress admin dashboard improved.
Use a Content Delivery Network (CDN)
CDN is short for content delivery network. These are a network of servers (also known as POPs) located around the globe. They are designed to host and deliver copies of your WordPress site’s static (and sometimes dynamic) content such as images, CSS, JavaScript, and video streams.
First off, you don’t want to get a CDN confused with your WordPress host. These are entirely separate services. A CDN isn’t a replacement for your hosting provider, but rather an additional way to increase the speed of your site. While our hosting here at Kinsta is blazing fast, a CDN can make your site even faster.
How a CDN Works
How does a CDN work exactly? Well, for example, when you host your website with Kinsta you have to choose a physical data center location, such as the USA, Europe, Asia-Pacific, or South America.
Let’s say you choose US Central. This means your website is physically located on a “host server” in Council Bluffs, Iowa. When people over in Europe visit your website it is going to take longer for it to load versus someone visiting it from say Dallas, TX.
Why? Because the data has to travel a further distance. This is what is known as latency. Latency refers to the time and or delay that is involved in the transmission of data over a network. The further the distance the greater the latency.
Types of CDNs
There are two different types of content delivery networks:
- Traditional Pull CDN
- Reverse Proxy CDN
Traditional pull CDNs cache a copy of all of your content and media, but a request from the client is still made directly to your hosting provider. KeyCDN and CDN77 are examples of traditional CDNs.
A reverse proxy CDN is slightly different. While it still acts likes a CDN, it intercepts all incoming requests and acts as an intermediary server between the client and your host. Cloudflare and Sucuri are examples of reverse proxy CDNs. This is one reason why you have to point your DNS directly to these providers instead of your host.
The benefit of these is because they act as an intermediary server, they can provide strong web application firewalls which can help block the bad traffic from ever hitting your WordPress site and or hosting provider. One downfall to this is that they do come with a little additional overhead in terms of performance compared to a traditional pull CDN. But with additional performance and security features, this could be argued as negligible.
Below is an example of what happened after enabling Sucuri on a client’s site. As you can see it had a dramatic impact on the amount of bad traffic that was coming through. In the end, these types of services can help you save on your hosting costs.
CDN Speed Tests
Earlier we talked about the huge benefits of WordPress caching. Well, CDN caching is also super powerful. This is because CDNs typically have a lot more server locations than hosting providers. This means they can cache all of your assets (images, JS, CSS) closer to your visitors and serve them up at lightning-fast speeds.
Let’s do a few quick tests to see just how much faster your site could be with a CDN.
Without CDN
Our test website is hosted at Kinsta and is physically located at the Iowa, USA data center. We first ran five speed tests in Pingdom (without the CDN enabled), and took the average. Important: We are using the Europe – United Kingdom – London location at Pingdom to demonstrate the real power of a CDN. The total load time was 1.03 s.
With CDN
We then enabled our CDN and ran five additional speed tests in Pingdom. Our total load time is now 585 ms from the Europe – United Kingdom – London Pingdom test location. So by using the CDN, we were able to decrease our page load times by 43.2%! That is huge.
The reason for such a drastic difference is because the CDN has a data center in London. This means all the assets are cached in that location and ready to be served with minimal latency.
TTFB without CDN
Remember that the yellow bar in Pingdom stands for wait time, which is time to first byte (TTFB). On our speed tests without the CDN running the average TTFB on assets was around 98 ms.
TTFB with CDN
Once we enabled the CDN, the average TTFB on assets dropped to an average of 15 ms. So by using a CDN our average TTFB dropped by 84.69%. This is primarily because the assets were being served directly from the CDN’s cache.