General WordPress optimization techniques

 

Overview

The following describes solutions to address issues that commonly lead to slow or inefficient WordPress websites.

If you find yourself in a situation that requires changes to your site and your developer isn't available to help, DreamHost's skilled support team may be able to assist you for a small fee. You can find more information about supported services and associated costs in the DreamHost Professional Services article.

Analyzing

The first step is to analyze your website to better understand the issue using online or browser tools.

Site load analysis tools

See the website loading tools article for a list of tools you can use to analyze your site. Such tools can provide insight into how your website is performing, identify issues that are causing your site to load slower than expected, and some tools even recommend solutions to help you troubleshoot further.

Browser tools

The following are a few recommended browser tools to help you troubleshoot performance issues with your WordPress site:

  • Firebug — A very handy tool that displays what is loading and how long it takes.
  • YSlow — A tool that provides some pointers on what to fix and how.
  • Web Inspector — Built into Chrome and Safari, it provides much of the same information as Firebug.

VPS or Dedicated Servers

Websites on VPS and Dedicated servers can use the K6 tool.

This is a load-testing service that hits your server with many simultaneous users. Before running it, be sure that you have caching enabled. During this process, you can log into your server via SSH and watch the CPU load with top, RAM levels with free—m, or both with vmstat 1 (Ctrl-C to stop).

Troubleshooting

Start with the following steps to troubleshoot your website. 

Troubleshooting your theme

Check theme reviews

Some themes are built more efficiently than others. Before deciding, check online reviews to see if any users have complained about site speed issues with that theme. 

Test the default theme

A quick way to check if your theme is the cause of any issues is to revert back to the default theme (such as Twenty Twenty-Four) and see if that resolves any issues with your site. To change the default theme:

  1. Log in to your WordPress dashboard.
  2. In the left pane, click Appearance > Themes.
  3. Search for the default Twenty Twenty-Four theme, and then click the Activate button.

If this improves your site's performance, proceed with using the following tools to further troubleshoot.

Viewing your access.log

Every DreamHost website stores access.log information about the site, which provides information about the pages receiving the most visitors.

These logs can become very large and difficult to read, so there are a few commands you can run to quickly tell which site is receiving the most traffic. See this article for further information.

Checking for missing files in your WordPress installation

If your WordPress installation is missing certain key files, a 404 error may display, which causes a server to work harder than normal as it tries to find them. This results in considerably slower load times, especially on popular websites.

The favicon.ico file

One of the most common missing files is the favicon (favicon.ico) file. DreamHost automatically generates a blank favicon for all domains by default, but if you notice it's missing, you can easily create a new one.

You can add one using an FTP client or by logging into your server via SSH. Once logged in, create a blank file in the root of your website's directory. This SSH example assumes it's in the /home/username/example.com directory.

[server]$ cd /home/username/example.com
[server]$ touch favicon.ico

This command creates a blank favicon.ico file. A blank icon is far better than a missing icon since your server will not work harder to find it.

To check for any other missing files, run your site through Pingdom Tools. A single pass shows you missing files that can cause your site to load slowly. Either replace them or remove references to them in your themes or posts.

Checking other common issues for poor performance

There are many more reasons why a site may run slower than you expect. See the following article for further information on how to troubleshoot other issues such as CSS, JavaScript, and other internet issues:

Optimizing

There are several ways to optimize your website to help improve performance.

Caching

Using a caching plugin

Caching creates static versions of your site, which means less data needs to be processed by the server when a customer visits your site. This allows your site to load a bit faster, and also helps manage larger amounts of traffic. There are a few ways to set up caching for WordPress with plugins, which are described in this article.

PHP Cache (OPcache)

OPcache is a caching engine built into PHP, which provides significant website speed improvements automatically. It is enabled by default on Shared, DreamPress, and VPS hosting plans, so if you're already using one of those plans, you do not need to enable it.

If you are on a Dedicated or DreamCompute Hosting plan, see this article for instructions on enabling it manually.

Database optimization

Using the WP-DBManager plugin

You should routinely optimize your database to avoid a "fragmentation" effect. The easiest way to do this is to use the WP-DBManager plugin, which optimizes your database as well as schedules this optimization to run at a desired time (recommended once per month at least). To use the plugin:

  1. Log in to your WordPress dashboard.
  2. Click Database in the left pane.
  3. Click Optimize DB under Database.
  4. Click the Optimize button on the page that appears.

Using wp-cli to optimize

See this article for instructions on using wp-cli to optimize your database.

Using SSH to optimize

See this article for details on how to optimize the database via SSH.

Optimizing via phpMyAdmin

See this article for details on how to optimize the database via phpMyAdmin.

Plugin optimization

See this article for information on how to manage your plugins.

Upgrading

Upgrading to DreamPress or a VPS

If you've tested the various suggestions described in this article and still seeing a high load on the server, then it could be that the traffic to your site has outgrown Shared Hosting. If this is the case, you may want to consider upgrading to a VPS or DreamPress plan, which provides more resources for your growing website.

If you have any questions about adding DreamPress or a VPS to your account, please contact DreamHost support for more info.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?