Dealing with WordPress on almost a daily basis there seems to be a lot of issues revolving around the CPU load caused by WordPress. Working on the system administration side of things as well as having a love for WordPress I decided to post up some things that I have seen help with lowering the load of a WordPress install. I know there are a dozen or more of these exact articles out there already, but I figured I might as well post this in hopes that I can help where others have not been able to.
1. Theme – If at all possible you want to look over your theme. While there are a lot of great theme developers out there, there are also a fair share of 15yr old kids out there that put together a theme for a class project in their HTML programming class. Often times in themes (I have done it myself) during the development you might include certain Java scripts that you really don’t use but forgot to get rid of upon the release. If you remove the excess code it can often speed up the loading of your site as well as help cut back on the CPU usage generated on every page load.
2. Images – Being on the Internet dating back to Windows 3.1 I have had to deal with slow loading pages and how to combat against them. I think a lot of that art form was lost over the years with faster Internet connections to each house hold. While having a faster connection it may not seem to make much of a difference how large and image is that you have on your site, but when the server has to serve a 1mb image time and time again it can cause high load and strain on the Web Server itself. By optimizing the images before you place them on your site can help aid in less load on the server, as well as your site loading even faster since it is less that the visitor has to download. If you are on a Windows machine you can download a program called IrfanView, its free and does wonders for optimizing images for the web. Adobe Photoshop does it as well, but that is priced a bit higher than the free mark.
3. Plugins – While we all enjoy our plugins since there is a plugin to accomplish just about anything, each plugin can cause CPU/Memory usage. While you dont want to disable them all take a look and see what really needs to be running and what you can go with out. Another good thing to do with plugins is shop around, chances are that there have been quite a few plugins released that do exactly the same thing. Read the reviews in the WordPress forums and see what others are saying. When it comes to stat plugins, take a look into something that is hosted off site such as Google Analytics. Since its not hosted on your account the load will be placed on Googles servers, which they dont have a hosting company breathing down their neck when things get busy and Google Analytics is an awesome service and can help you monitor your SEO even. If you decide not to go with Google Analytics, you can always just base your stats off of the stats program that comes with your host such as AWStats, might as well just use what is already being ran on your server. While disabling some plugins will help lower the load, enabling some will also help. Probably one of the best ones that you can install and enable is WP-Super-Cache. Installing this caching system can often times in itself drop the load that your site is causing by up to 50%. it works by creating a static page and serving that to your visitors instead of generating a new page on every load.
4. More Tweaks – If you are still experiencing issues even after all that you can try some of the following as it can sometimes cut back the load especially if you write a lot of articles and do multiple revisions before you publish.
If you edit the wp-config.php you can add the following snippit of code
// Disable the post revisions
Applying this will make so that WordPress stops tracking post revisions. For most people this will be totally fine to have this disabled. Once you disable it you will want to run the following command in MySQL. If you are not familiar with MySQL you should have access the phpMyAdmin as most hosts give you access to this in some form or another.
DELETE FROM wp_posts WHERE post_type = “revision”;
Once you have run that it should show that it removed X entries, those were all the past revisions even for posts that you have already published.
You may have noticed that WordPress autosaves your posts while you are typing. Every time that it saves it is going to use the servers processor to run the needed queries against the database and save your post. While this is wonderful and all, you may choose to raise the interval to a higher number. The higher the number means its not going to save as often, and will not hit the CPU as often either. To make the adjustment open the wp-config.php file again and add the following line and adjust the number so something that you see fitting. It is in seconds.
define( ‘AUTOSAVE_INTERVAL’, 1200 );
Doing all of the provided steps should help you lower the load your WordPress blog is putting on the server and provide a faster loading site for your audience.