General WordPress optimization techniques

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 could occur, and this article walks you through some of the most common issues and provides solutions to help you resolve them.

Database

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 capability to schedule this optimization to run at an appropriate time frame (recommended once per month at least).

FastCGI

You can activate DreamHost's PHP FastCGI options which should improve your PHP code execution. If you are on a private server, you also have the option to activate XCache support which will further improve your PHP execution.

Some sites that have a lot of spam/bot/spider traffic could see a large increase in memory saturation when switching to FastCGI. If memory spikes are a problem, try switching to CGI and use a good caching plugin.

Image Size

The size of your images can also contribute to a slow loading site. The larger your images, the longer it will take for it to download on the user's end. So you will want to make sure that your images are as small as possible. Please read over these instructions on how to optimize your images

Missing Files

Sometimes, due to upgrades or some poorly coded pre-packaged themes, your WordPress install might have some missing files. Missing files make the server expend a little extra effort and can drive up load considerably on a popular site. One of the most common missing files is the favicon (favicon.ico). If you've recently used the One-Click Installer, a favicon should be generated for you — but it never hurts to make sure one exists in the main directory for your site.

Adding a favicon if one doesn't already exist is easy. It does require SSH access however. In the root directory of your site (i.e. /home/username/example.com/), type:

[server]$ touch favicon.ico

This command creates a blank favicon.ico file. But a blank icon is far better than one that is missing.

To check for any other missing files, you can run your site through Pingdom Tools. A single pass through their site will point out any missing files that could be causing your site to load slowly. Just look for filenames in red and then either replace them or remove references to them in your themes or posts.

Page Speed Optimization

View the following article for further details:

Themes

Using a good theme can be challenging. While the ones on wordpress.org are free and safe to use, some are going to be better than others. A fast way to see if your theme is the problem is to change to the default theme (such as TwentyFifteen) and see if that helps your site. When shopping for a theme, do some Google searches to see if people have complained about site speed with that theme. You'd be surprised what you find out.

Tools

Here are a few 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 might give you some pointers on what to fix and how.
  • Web Inspector: Built into Chrome and Safari, it gives you much of the same information as Firebug.

Only use the following if you are using a VPS or Dedicated server:

  • Load Impact: A load testing service that hits your server with many simultaneous users. A free version does a 50 user test. Be sure that you have caching enabled before running. 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).

Upgrading to DreamPress or a Private Server

If you've tried the plugins and suggestions but are still seeing a high load on the server, then it could be that the traffic to your site has outgrown shared hosting. At this point you may wish to 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.

Widgets

Be suspicious of all widgets (or sidebar content) that will force the user to poll other DNS servers. This may delay the loading of the site.

Also, check if your theme is using custom widgets to draw recent comments of posts. If this is not handled correctly, it will poll the database every time which increases your site's load considerably.

If you're using a lot of widgets, a good option is to use a Widget Cache plugin (in addition to standard caching) to reduce the processing time for their output.

XML-RPC

WordPress uses the xmlrpc.php file for remote administration purposes such as posting via third party applications. However, this file can be a target for attackers.

To protect your site, DreamHost has implemented rate-limiting on this file. You can disable xmlrpc.php although some plugins which depend on it (like Jetpack) may no longer work if you do.

See also

Internal links

External links

Did this article answer your questions?

Article last updated .