How to Speed Up WordPress – Part I

iPage Affordable Web Hosting only $3.50/mo

wordpress speedup tutorial 300x294 How to Speed Up WordPress   Part I

How to Speed Up WordPress – Part I

Be wise with speed; a fool at forty is a fool indeed.” – Edward Young

Many people encounter the problem of “Slow WordPress“, especially when they are using the standard setup with whatever plugins they have installed. The biggest issue here is that the larger service load becomes, the sooner your hosting provider will ask you to “move up” to the more expensive service plan. I have been there in the past when I was creating satellites for sites using WordPress, and when the daily traffic was crossing 1,000 visitors the site would become noticeably slower even under the most expensive service plans. I tried caching and deleted bunch of plugins, but that didn’t help.

Being a stubborn son of a gun, I kept looking for ways to decrease the server load and to increase the speed of my sites built with WordPress. This is part one of the series of tutorials on how to increase the speed of your WordPress blog. Feel free to refer to this post anytime you or your friends need a rock solid guide on how to speed things up. Ready? – Let’s get it on!

Before even starting the speed up process of your WordPress you will need to give a good thought to your hosting service. Maybe a small increase in service plan cost (perhaps to the next one in the price range) or even moving to a different hosting service will solve your problems. Sometimes you just have to make that move, since it’s impossible to keep large projects on cheap hosting service. I can recommend this hosting service: Whatever.com

Step 1: Preparations

First of all, you will need to update your WordPress version to the most current. You can either download it from here or update from within your WordPress. I usually update from within the WordPress Admin area. In order to do this easily, you need this plugin.

Step 2: wp-config.php

File wp-config.php – is WordPress configuration file that is located in the root directory of your WordPress.

I would like to share some methods using which we can decrease the server load of your site:

2.1. The original version (comes standard) has a wasteful option in it, which is to have a various language support files for the admin and the main area of your site. If we will use only one file (your language file) then it will let us significantly decrease the load. In order to do this we will need to change the following line of code:

define (‘WPLANG’, ‘eng_ENG’);

to this:

if (strpos($_SERVER['REQUEST_URI'], ‘wp-admin’)) define (‘WPLANG’, ‘eng_ENG’); else define (‘WPLANG’, ‘eng_ENG_lite’);

2.2. Also, I recommend to define the needed amount of revisions when writing a post.

Revisions – are drafts, which get automatically saved when you are writing your post, which lets you go back if your power went out or your dog runs around restless and accidentally unlugs the computer from the outlet (because you forgot to take the dog for a walk). I use one revision that gets rewritten every 60 seconds, and on some of the sites I turn it off completely, since I use the external content writer. Turning off revisions speeds up the redactor speed as well as your WordPress.

In order to only have one revision saved every 60 seconds, you need to add the following line into the same wp-config.php before the last closing “?>:

define( ‘AUTOSAVE_INTERVAL’, 60 );
define(‘WP_POST_REVISIONS’, 1);

and if we want to turn the revisions off, then insert the following code:

define(‘WP_POST_REVISIONS’, 1);

Step 3: Robots.txt

Robots.txt – is a text file, located in the root directory of your site, which includes the special instructions for the search robots. These instructions can restrict indexing some of your pages or areas of your site, point out the correct “mirroring” of your domain, recommend the time interval (determined by you) between the search engine robot’s allowed download of the documents from the server (your hosting service).

Remember that search robot visits to your site will increase the load significantly. If you target only a certain group of visitors you can restrict visits by e any search robots anytime. Some webmasters prefer to only let Google, Yahoo and Bing visit and index their site. All other bots (including some parsers and grabbers, that will steal your content) is denied access. To accomplish this, you will need to add the following lines into your Robots.txt file.

If you do not have Robots.txt, you need to first create it in your root directory (/public_html). The effect will be gradual – usually in a few weeks to a month the restricted bots will stop visiting your site.

If you also want to deny Yahoo bot, which will not only decrease your server load but also will hide the back links (Yahoo version), then you need to add these lines to your Robots.txt as well:

User-agent: Slurp
Disallow: /


Step 4: .htaccess

.htaccess – is a file of additional server configuration. Using this file we can create additional commands to the server, which will be processed before your site is loaded.

4.1. In today’s mean online world it is becoming very popular to cheat and copy (steal) someone else’s information or content. Mostly this is done using automated programs. These programs copy not only the text, but also images from your site. Since the links to the images from the thief sites link back to your site, it means that the server load on your server will go up as well. This is called “hotlinking”. There is a way to fight this “bs” and I will teach you how.

There are two ways to fight this issue. First – is to replace the images on all sites, that use your server. Image that will be displayed on a site (not yours) can be for instance replaced with a advertisement banner. Here is the code for .htaccess:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?undsoft\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yandex\.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?feedburner\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mail\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourdomain\.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule .*\.(jpeg|jpg|gif|bmp|png)$ stophotlinking.gif [L]

In the code above you need to replace “yourdomain” with the name of your domain and the zone to your zone, if it’s different from “.com”. The image that will be shown in the thief sites should be located in the root directory of your site and the name should be “stophotlinking” and format “gif”. If you change it, make sure to reflect those changes in the code above.

This method does not stop search engines robots to gather images from your site, since they are in the permitted area in your .htaccess code (code above). You probably noticed that there is no Google in the list. That’s right, this is because Google uses cached version of your site and the method above will not stop Google from gathering info from your site (you want Google to do it).

Please keep in mind the approach above has one disadvantage – it will not reduce the server load on your hosting, since the advertisement banner will still be hotlinked to from all the thief sites using images from your stolen content.

Now let’s look at the approach that will bring the server load to “0″ (yes, zero). In the code above replace this line:

RewriteRule .*\.(jpe?g|gif|bmp|png)$ stophotlinking.gif [L]

With this one:

RewriteRule .*\.(jpe?g|gif|bmp|png)$ – [F]

This will replace images with the error message and make thief’s life harder.

If for some reason the approach above didn’t work for you (your hosting service has restrictions on how you can work with the .htaccess file), use the alternative code below:

RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your “don’t hotlink” image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

4.2. Using .htaccess you can make caching of the jpg, css, gif, png, js and other file types in the user’s browser for a day. This can be done using the code below. Please note if there are updates in the content, the cache will be updated as well:

FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch “.(jpg|gif|png|css|js)$”>
ExpiresActive on
ExpiresDefault “access plus 1 year”
</filesmatch>
</ifmodule>

Please note, the browser must have caching enabled.

4.3
. I also recommend doing the automatic compression of the files in GZIP before sending them to the user, so the site is loaded faster. In order to do this, you will need to enter the following code into the .htaccess file:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Please note, you cannot use both GZIP and ZLIB compression at the same time. You will need to use one or the other.

4.4. Practically every WordPress site has to deal with the problem of spam. In order to cut off all the spam before it even gets registered in WordPress, you can filter the spam boys via Referrer.

Referrer – is a request header of the client that will show you from which page the user just came to the current page. Since the spam programs create a direct move to the comments skipping everything else (spam programs are not interested in what you are writing about, they want back links), we can cut them off right there. This doesn’t mean you can delete your spam plugins, but this will allow you to decrease the quantity of spam and most importantly the server load. In order to accomplish this, you will need to enter the code below into your .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]

Please do not forget to change the “yourdomain.com” to the address of your site.

4.5. Many people use plugin to re-address the standard RSS to Feedburner. This can also be done without the plugin by inserting the following code into your .htaccess, thus decreasing the server load:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds2.feedburner.com/profitseocom [R=302,NC,L]

If the redirect didn’t work, try placing the code above in the beginning of your .htaccess file.

Please do not forget to replace the “http://feeds2.feedburner.com/profitseocom” with address of your feedburner.

There is more useful information coming up in the next parts of the “How to Speed Up WordPress” series of tutorials. Stay tuned and Marry Christmas to you and your family!

Beck @ ProfitSEO.com

This video was embedded using the YouTuber plugin by Roy Tanck. Adobe Flash Player is required to view the video.

Many people encounter the problem of “Slow WordPress”,

especially when they are using the standard setup with

whatever plugins they have installed. The biggest issue

here is that the more service load becomes, the sooner your

hosting provider will ask you to “move up” to the more

expensive service plan. I have been there in the past when

I was creating satellites for sites using WordPress, and

when the daily traffic was crossing 1,000 visitors the site

would become noticably slower even under the most expensive

service plans. I tried caching and deleted bunch of

plugins, but that didn’t help.

Being a stubborn son of a gun, I kept looking for ways to

decrease the server load and to increase the speed of my

sites built with WordPress. This is part one of the series

of tutorials on how to increase the speed of your WordPress

blog or site. Feel free to refer to this post anytime you

or your friends need a rock solid guide on how to speed

things up. Ready? – Let’s get it on!

Break here

Before even starting the speed up process of your WordPress

you will need to give a good thought to your hosting

service. Maybe a small increase in service plan cost

(perhaps to the next one in the price range) or even moving

to a different hosting service will solve your problems.

Sometimes you just have to make that move, since it’s

impossible to keep large projects on cheap hosting service.

I can recommend this hosting service: Whatever.com

Step 1: Preparations

First of all, you will need to update your WordPress

version to the most current. You can either download it

from here

http://WordPress.org/download/

or update from within your WordPress. I usually update from

within the WordPress Admin area. In order to do this

easily, you need this plugin

http://WordPress.org/extend/plugins/WordPress-automatic-

upgrade/

Step 2: wp-config.php

File wp-config.php – is WordPress configuration file that

is located in the root directory of your WordPress.

I would like to share some methods using which we can

decrease the server load of your site:

1. The original version (comes standard) has a wasteful

option in it, which is to have a various language support

files for the admin and the main area of your site. If we

will use only one file (your language file) then it will

let us significantly decrease the load. In order to do this

we will need to change the following line of code:

define (‘WPLANG’, ‘ru_RU’);

to this:

if (strpos($_SERVER['REQUEST_URI'], ‘wp-admin’)) define

(‘WPLANG’, ‘ru_RU’); else define (‘WPLANG’, ‘ru_RU_lite’);

2. Also, I recommend to define the needed amount of

revisions when writing a post.

Revisions – are drafts, which get automatically saved when

you are writing your post, which lets you go back if your

power went out or your dog runs around restless and

accidentally unlugs the computer from the outlet (because

you forgot to take the dog for a walk). I use one revision

that gets rewritten every 60 seconds, and on some of the

sites I turn it off completely, since I use the external

content writer. Turning off revisions speeds up the

redactor speed as well as your WordPress.

In order to only have one revision saved every 60 seconds,

you need to add the following line into the same wp-

config.php before the last closing “?>:”

define( ‘AUTOSAVE_INTERVAL’, 60 );
define(‘WP_POST_REVISIONS’, 1);

and if we want to turn the revisions off, then insert the

following code:

define(‘WP_POST_REVISIONS’, 1);

Step 3: Robots.txt

Robots.txt – is a text file, located in the root directory

of your site, which includes the special instructions for

the search robots. These instructions can restrict indexing

some of your pages or areas of your site, point out the

correct “mirroring” of your domain, recommend the time

interval (determined by you) between the search engine

robot’s allowed download of the documents from the server

(your hosting service).

Remember that search robot visits to your site will

increase the load significantly. If you target only a

certain group of visitors you can restrict visits by e any

search robots anytime. Some webmasters prefer to only let

Google, Yahoo and Bing visit and index their site. All

other bots (including some parsers and grabbers, that will

steal your content) is denied access. To accomplish this,

you will need to add the following lines into your

robots.txt file:

Similar Posts:

Popularity: 8%

2 Responses to “How to Speed Up WordPress – Part I”

  1. Thanks for these useful information.

  2. You are welcome. Happy Holidays to You and Your Family!

Leave a Reply