Make Wordpress Load Much Faster
If you are suddenly receiving a lot of request within a short period of time because you’ve been linked by a large site like Digg or Slashdot, your hosting solution might not be able to handle the load.
This article should help your to prepare your WordPress blog for such a case or if you’re just using a slow webhost and want to improve the general performance.
Select a Minimal Theme
Plaintxt.org has some great minimal themes for Wordpress, as does CSSJuice, and of course the Wordpress Extend site as well.
4-5 posts per page
Go to Settings –> Reading –> and change “Blog pages show at most” to 4 or 5. The less content displayed per page, the faster the page will display.
Limit number of widgets and plugins
This one is simple enough. There are a lot of plugins and widgets that are neat, but you need to keep it down to what is absolutely needed by your site. What you don’t need, don’t leave laying around in your plugin directory either. Delete it through the Plugin page or via your OS.
WP-SuperCache / Gzip compression
One plugin that you absolutely need is the WP-SuperCache. This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
WP-SuperCache also can take advantage of Apache’s compression abilities. If you go to Settings–> Wp-SuperCache and enable compression as well as mod_rewrite functionality and follow the instructions on that page to change your .htaccess file, not only will pages be cached but also served up compressed making for a faster transfer.
Compress your CSS
The plugin is called css-compress. It just has to be activated in the plugin tab in Wordpress. The advantage of using css-compress is that css-compress compresses all css files even those of third parties such as those from advertisers or other plugins. It removes comments and blank spaces within the css files without damaging their function.
Mysql Query Cache
Since pages are served dynamically every page load in Wordpress results in a Mysql Query, as stated before the WP-Cache plugin helps to reduce these queries but it’s also important to make sure you have the Query Cache optimised for maximum performance.
To activate the Mysql Query Cache:
- Find your mysql configuration file my.cnf
- Find the setting query-cache-type & change the value to 1
- Find the query-cache-size & change the value to 20M
- Find the query-cache-limit & change the value to 2M
You will need to make sure your host allows root access to the server in order to do this tweak.
Optimising your Mysql Database with PhpMyAdmin
Optimising your Mysql Database can have a huge performance on your load times & load on the server, especially if you have a big database.
Optimising your Mysql database is pretty easy:
- Log into PHPMyAdmin (if you have it enabled)
- Locate your Wordpress DatabaseTables
- Make a Backup First
- Check all the tables in the Check Boxes
- Select the Optimize Tables Option
If you don’t have phpmyadmin installed, there are 2 wordpress plugins that can perform the same function; WP-DBManager and OptimizeDB.
Replace some PHP with static HTML
Those wonderful themes that we all choose are often loaded with PHP bloat. Some themes are designed mainly for looks (I’m not going to name any names). But all of them have some very generic code in them to allow them to be easily installed on any blog.
This generic PHP code can be replaced with some static HTML in order to save CPU processing time and database queries, and under load this can make a big performance difference.
The way to fix this is quite simple. If you examine your theme’s Header.php file in your Presentation > Theme Editor tab in the control panel you will find some lines that look somewhat like the following:
<title><?php bloginfo(’name’); ?> <?php bloginfo(’description’);?></title>
<link rel=”shorcut icon” type=”image/x-ico” href=”<?php bloginfo(’template_url’); ?>/favicon.jpg” />
<link rel=”stylesheet” type=”text/css” media=”screen” href=”<?php bloginfo(’stylesheet_url’); ?>“/>
<link rel=”stylesheet” type=”text/css” media=”print” href=”<?php bloginfo(’template_url’); ?>/print.css” />
<link rel=”alternate” type=”application/rss+xml” title=”RSS .92? href=”<?php bloginfo(’rss_url’); ?>” />
Now, if you take a look at the bolded segments, that is the PHP code mixed in with the HTML. In this example, there are 5 different PHP commands which need to be executed every time the page loads, and they go and pull this information from the database based on what you entered into the blog’s options menu. Since we don’t need the theme to be portable to other blogs anymore, we can eliminate those 5 PHP executions and replace them with plain HTML which is about 20 times faster!
To do so, load your blog in a normal browser window and select “View Source”. You should then see the finished code that had the PHP processed and replaced. In the case of this example, the following were the finished result:
<title>TuxTraining.</title>
<link rel=”shorcut icon” type=”image/x-ico” href=”http://tuxtraining.com/wp-content/themes/simple/favicon.jpg” />
<link rel=”stylesheet” type=”text/css” media=”screen” href=”http://tuxtraining.com/wp-content/themes/simple/style.css”/>
<link rel=”stylesheet” type=”text/css” media=”print” href=”http://tuxtraining.com/wp-content/themes/simple/print.css” />
<link rel=”alternate” type=”application/rss+xml” title=”RSS .92? href=”http://otuxtrainingcom/feed/rss/” />
Now, all we need to do is replace that original PHP code with the already processed code and save the Header.php file. That’s it! You’ve saved yourself 5 PHP executions, and when a blog gets some heavy traffic that adds up very, very quickly. Try looking in the Footer.php file too because there is often content there that can be converted to HTML as well.
You can also remove date stamps if they are not important to you as well. To do so, go into the Theme Editor and select the single.php and Main Index templates and take out this code:
< ?php the_time(‘F j, Y’); ? >
Depending on theme, the line above may vary.
PHP Compiler Cache
The PHP Compiler cache saves scripts in their compiled format on the server so that they’re not getting recompiled every time you call them from Wordpress.
It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimises scripts to speed up their execution. It typically reduces server load and increases the speed of your PHP code by 1-10 times.
Two popular Compiler Caches are APC & eAccelerator however I’m not going to go into any details about installing or configuring them.







