How can I improve the performance of my WordPress website?

I’m often called to help folks with hacked websites, and later asked the question, “How can I improve the performance of my website (WordPress blog)?”

Below are a few things I’ve learned over the years to improve the performance of a WordPress blog (in lieu of throwing hardware at “the problem”).

Did you know?
Unlimited shared hosting is “limited” by your web host.

Surprisingly, many believe that because they have unlimited space and bandwidth they they’re allowed unlimited server resources as well. This is one of those little secrets within the shared web hosting industry. Server resources like number of processes allowed and memory are virtually always limited per account.

Though with a few minor tweaks you may be able to squeeze a bit more blood from that shared website hosting turnip.

Let’s start with your wp-config.php file. The wp-config.php file contains your WordPress blogs settings. This one file governs how your website interacts with your website’s database (where your post content lives).

Sample of php.ini file
About that
"Fatal error: Allowed memory exhausted"

Ok, maybe you have not yet experienced this specific error, though an error like this may appear when a plugin begins using up all of the memory allocated to your website. To help prevent this error from occurring, and/or give your site a bit more than the default memory allowance, add this to the top of your wp-config.php page (see image at right):*

define('WP_MEMORY_LIMIT','128M');

*Sadly, this does not always work. Alternately try adding to the bottom of your wp-config.php file instead.
If that does not work then see the alternate php.ini method below.


About that wp-cron.php

The wp-cron.php scripts does things like check for theme and plugin updates, publishes scheduled posts, sends pingbacks, etc.. This script runs every time someone visits a page on your website. This may cause slowness particularly if you have a busy blog, and may even raise server load (which some web hosts may find objectionable). The solution is simple enough:*

  1. Disable wp-cron.php by adding the below line to your wp-config.php file (see image at right):
    define('DISABLE_WP_CRON', true);
  2. Then create a cron job to run this script every 5 minutes (instead of every page load). Example cron command:
    wget http://yoursite/wp-cron.php > /dev/null 2>&1

*Does not work with a WordPress Multi-site setup.


Caching is your friend

Plugins like W3 Total Cache or WP Super Cache help to reduce process usage and website memory usage while improving your visitors perceived page loading speed.

Dislike caching plugins, need a speed boost and feel comfortable modifying your .htaccess file?
Try this mod_expires remedy for some added juice:

*max-age specifies the maximum amount of time that an object will be considered fresh. For example, max-age=31536000 specifies that a response can be read from cache for 1 year.


Limiting plugins

More plugins equal more complexity, ergo potentially slower website. Be smart when choosing plugins. Look for well rated plugins with multiple features. A good example of a well rounded plugin is Better WP Security. Better WP Security helps reduce the likelihood you’ll be hacked; includes a nifty bot blocking option; login management; and provides a very cool real-time file-change-monitor as well.


php.ini and how to tame it

At some point in your web design career you’ll meet Mr. php.ini. The php.ini file is simply a file used by the web server to control specific options within your account. Like the wp-config.php, and .htaccess file, the php.ini file is just another dumb text file. You may edit this file via your computer’s text editor or use the File Manager provided by your host.

The php.ini file lives in your public_html directory with your other website files. If the file does not exist just create a blank one like you would any blank HTML file.

Edit the existing setting or add these lines:*

memory_limit = 128M
max_execution_time = 60

*Either of these settings, memory_limit or max_execution_time may be set higher or lower depending on your web hosts allowances. This site for example is set to a memory_limit of 256 and max_execution_time of 600.
*If you find your php.ini settings are not working, try copying the php.ini file into the wp-admin directory as well.
*If after following all of the advice above your memory limits are still not “sticking,” then Google this phrase as an emergency option, “default-constants.php WP_MEMORY_LIMIT”


About that database

Have you ever had to run a defragmentation program on your computer hard drive?
WordPress requires much the same “defrag” process to keep fresh and lively.

“Don’t let DB bloat get you down. Optimizing your
DB once a month is simply good for business.

But before we get into how to optimize, let’s start by preventing much of that bloat from happening in the first place.

Did you know that every time you make a change to a post, a backup of the old post is saved?

While a helpful feature, saving post revisions is fairly wasteful as well. On a busy website, this setting can turn a normally speedy website into a perpetual Thanksgiving day after turkey lunch experience.

Add the below line of code to your wp-config.php settings file:

// Limit number of saved revisions to one
define('WP_POST_REVISIONS', 1);

Now back to database optimization. Install the WP-DBmanager plugin, optimize your database today, then set to optimize once per month.


In summary

While there are many ways to further improve the performance of WordPress, like replacing your theme or reducing widget usage, the items described above tend to return the most dramatic improvements with the least amount of effort.

Other dramatic improvements may be seen by utilizing services like Cloudflare; having Nginx or Varnish installed; or by upgrading your hosting plan to a plan which provides more memory for your specific hosting account.

Summary
Article Name
How can I improve the performance of my WordPress website?
Author
Description
Below are a few things I've learned over the years to improve the performance of a WordPress blog
The following two tabs change content below.

hackrepair

Jim Walker, +Hackrepair, is a WordPress security expert. He runs HackRepair.com, a malware cleanup and website security service, and HackGuard.com, a WordPress management service. Jim has likewise provided business management services for web hosting company TVC.Net since 1997.

Latest posts by hackrepair (see all)

Please feel free to comment via WordPress, Twitter, Facebook or Google+