Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

How to speed up WordPress?

Friday, October 22nd, 2010 by Markus

Using WordPress? Wow cool, then this article can be very interesting for you!

Can I speed up my WordPress ? Can I reduce the hit-count ? … Yes YOU can!

The first thing you can do, is to reduce the count of HTTP requests.

If you  are using plug-ins, watch them carefully for inefficiencies like added CSS and JavaScript files. Combine, minify and compress these files. Some plug-ins allows you to turn off their bundled CSS file in the settings page of the plug.in. Where possible, copy the plug-ins CSS into the current theme’s style.css and turn off the extra file.

Also you can disable or remove plug-ins you’re not using. (Only disabled plug-ins can be removed!) Thats very important as all plug-ins are active for any visitor, even when not used. Also take care of 3rd party plug-ins that are not published and accepted from WordPress it self. They are not maintained in case security issues and often written in very bad code (performance)!

This may help you to speed up the loading of your page, as every single HTTP request costs time. So try to minimize the count of external referenced files wherever possible.

Speed up by editing the MOD_REWRITE functions

I have found a good example written by jdMorgan that can double the speed of your page, or even more! And it works :)

The following code is adopted to the most generic websites, feel free to optimize this .htaccess settings for your website and needs. Example: add or remove specials like tiff or mpeg container..

This is a example to replace the original .htaccess file that comes with WordPress.

# adapted from jdMorgan
RewriteEngine on
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive RewriteBase /
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(jpg|gif|png|ico|css|js|flv|swf)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]

Flush your buffer.

The first page-load will normally take between 300 and 700 ms. In this time the first HTML page is generated. If you are using the PHP flush() function it allows you to send partially ready rendered HTML contents to the web-browser so the browser can start fetching components while your back-end is busy with the rest of the HTML page. The benefit is on our servers your page is loading much faster as the server is generating multiple sites at once which are load balanced across the entire cluster.

A short example how you can add the flush() PHP function between the closing tag and the opening tag in your header.php


</head>

<?php flush(); ?>

<body>

This example will sent the header of the page to the browser and continues to render the main content. The trick here is that the header references the CSS-Stylesheets and some JavaScript/DOM code, which already can be loaded from the server and be validated while the server still is rendering the main content of the page.

Optimize the MySQL Database

To optimize your WordPress database, use phpMyAdmin. Below the structure tab click on the link “Check all” at the bottom and use the option “Optimize table” in the pull-down menu behind. Now the Database will automatically optimize it to the best result. Do not wonder, when your wp_posts table was reduced for example 500MB down to 250MB …Thats OKAY! :) , as the MySQL server will remove unused data from the RAW database files which is not done automatically by the server during normal operation.

MySQL explains for the MyISAM table, OPTIMIZE TABLE works as follows:  (Taken from)

  • If the table has deleted or splited rows, repair the table.
  • If the index pages are not sorted, sort them.
  • If the table’s statistics are not up to date (and the repair could not be accomplished by sorting the index), update them.

Hold your database clean

1. Delete spam comments

You can do it from the Dashboard by clicking on Comments and then click on “Empty Spam”.

2. Delete your post revisions

You do not use revisions? Okay thats perfect! You may want to delete them from the wp_posts table. But please take a backup of your database before you start, if you are not sure what you’re doing!  The simplest way to do that is to use the following  SQL query (in phpMyAdmin):

DELETE FROM wp_posts WHERE post_type = "revision";

This does not delete the latest draft of unpublished posts. It is a good idea to optimize the table after deleting the revisions.
If you want to stop WordPress from automatically creating new revisions you can define the following in the wp-config.php file:

define('WP_POST_REVISIONS', false);

The WP Super Cache!
And now the most significant plugin you MUST have! The WP Super Cache, it’s incredible how this plugin speed up your website!

WordPress writes:

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.

The static html files will be served to the vast majority of your users, but because a user’s details are displayed in the comment form after they leave a comment those requests are handled by the legacy caching engine. Static files are served to:

  1. Users who are not logged in.
  2. Users who have not left a comment on your blog.
  3. Or users who have not viewed a password protected post.

99% of your visitors will be served static html files! Those users who don’t see the static files will still benefit because they will see regular WP-Cache cached files and your server won’t be as busy as before.

That should do it for now. Hopefully, a few of these tips will help to make your WordPress perform in a much faster way.

Do you also have some favorite tips? Leave a comment below and let us know!

How to speed up WordPress?, 3.7 out of 5 based on 14 ratings
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

6 comments (leave a comment)

W3 Total Cache may very well be the greatest plugin on the planet for speeding up WordPress.

Vote for it on WPHonors here http://2010.wphonors.com/plugin/w3-total-cache/

Wow, fantastic … wish I was clever enough to actually do all that! Will just have to run with a slower blog.

dos servage support gzip?

What do you mean? Gzip files can be uploaded and downloaded to/from your account. I don’t know about the Filemanager in the control panel. Try tit out, or contact the support.

robert…

excelent post, keep it coming…

I would like to see an article:

Hoe to speed up Servage Server for typo3 sites. I have severe problems with my typo3 sites. My other CMS-based sites and plain XHTML+CSS sites run OK.

But my two typo3 sites are frequently hardly reachable: homepage opening takes a minute is no exception.

Leave a comment

You must be logged in to post a comment.