General WordPress optimization techniques

Over time, you may notice that your WordPress site runs slower or doesn't run as well as it should. There are several reasons this can occur.

The following article describes some of the best potential solutions to address issues that commonly lead to slow or inefficient websites.

Caching

Using a caching plugin

Caching creates static versions of your site, which means a lot less has 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 on the following page:

PHP Cache (OPcache)

OPcache is a caching engine built into PHP. When enabled, you’ll enjoy significant website speed improvements automatically.

Does my hosting plan support OPcache?

It is enabled by default on Shared and DreamPress hosting plans, so if you're already using one of those plans, you do not need to enable it.

If you are on a VPS, Dedicated, or DreamCompute hosting plan, follow the instructions in the following article to enable it manually.

How to Optimize your database

Using the WP-DBManager plugin

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

Once installed, click 'Database' in the left pane:

WP-DBManager

Under 'Database', click 'Optimize DB' and then click the Optimize button.

Using wp-cli

You can also use wp-cli to optimize your database. Log into your server via SSH and make sure you're in your WordPress site's directory. Run the following command to view all database command options:

[server]$ wp help db

To optimize the database, run the following:

[server]$ wp db optimize

Using SSH to optimize your database

See the following article for details on how to optimize the database via SSH:

Optimizing via phpMyAdmin

See the following article for details on how to optimize the database via phpMyAdmin:

Plugin optimization

View the following article for information on how to manage your plugins:

Checking your theme

Using the optimal theme can be a challenge. While the available themes on wordpress.org are free and safe to use, some are better than others. When shopping for a theme, be sure to search Google to determine if any users have complained about site speed with that theme. These results can greatly help you determine which theme is best for you.

A quick way to check if your theme is causing issues with your site is to revert back to the default theme (such as TwentySeventeen) and see if that resolves any issues with your site.

To change the default theme:

  1. Log into your WordPress site's panel.
  2. On the left pane, click 'Appearance > Themes'.
    WP_activate_theme
  3. Search for the default 'TwentySeventeen' theme, and then click the Activate button.

Your site changes its appearance to the TwentySeventeen theme. Use the online tools above to check if this improves your site's performance.

Determining which pages receive the most visitors

Every DreamHost website stores access.log information about the site. 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 the following article for further information:

Upgrading to DreamPress or a Private Server

If you've tested the various plugins and suggestions as 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 can consider adding a Private Server or DreamPress to your hosting package.

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

Optimizing image sizes

The size of your images can often cause a site to load slowly. The larger an image, the longer it takes for it to download on the visitor's end, so you'll want to make sure that your images are as small as possible while still preserving their quality. You can read more about how to optimize your images, as well as using a plugin to help you do that, such as:

Minifying your scripts

You can also minify your HTML/CSS/JavaScript code to help improve the time it takes to load your site. There are various plugins you can install to help you minify this code, and you may need to do a little trial and error to find which one works best for your site. Here are a couple options:

Using a CDN to deliver static files

You can use a Content Delivery Network (CDN) to deliver static files such as images, video, CSS, and JavaScript files, which can help improve the speed in delivering these files to your site's visitors. 

Are there any missing files in my WordPress installation?

Your WordPress installation may be missing certain key files. This can result in 404 errors and can cause a server to work harder than normal as it tries to find them. This results in considerably slower load times, especially on popular websites.

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.

Adding a favicon if one doesn't already exist is simple to do. 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. If you're creating it via SSH, run the following commands after logging in.

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

This command creates a blank favicon.ico file. A blank icon is far better than one that is missing, since your server will not work harder looking for it.

To check for any other missing files, you can run your site through Pingdom Tools. A single pass through the site shows you any missing files that can cause your site to load slowly. Simply look for filenames in red and then either replace them or remove references to them in your themes or posts.

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:

Using online tools

Site load analyzation tools

There are various online tools you can use to analyze your website. 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.

View the following article for a list of tools you can use to troubleshoot your site:

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 companion to Firebug that can provide some pointers on what to fix and how.
  • Web Inspector — Built into Chrome and Safari, it provides much of the same information as Firebug.

If you're running WordPress on a VPS or Dedicated server

You can use the following tool to check your VPS or Dedicated server:

  • Load Impact — A load testing service that hits your server with many simultaneous users. The free version provides a 50-user test. Be sure that you have caching enabled before running it. During this process, you can watch the CPU load with 'top', and RAM levels with 'free -m', or both with 'vmstat 1' (Ctrl-c to stop).

See also

Internal links

External links

 

Did this article answer your questions?

Article last updated .