Most Essential Tips for Improving Response Time of Your WordPress Blog

May 19, 2013 · 94 comments

by Lars

wp-performance

WordPress is one of the most popular blogging and CMS platforms to date. What makes it unique is the fact that it satisfies the needs for both start-ups and very serious bloggers and businesses. The community is world class and you can get a very professional CMS and endless functional extensions for free. WordPress sets new standards when it comes to support for building templates and it so easy to get started with and still so powerful that most people won’t let it go even if they run into serious success. Some of the really high traffic blogs out there run on WordPress! ex smashingmagazine, mashable that both have millions of hits every month. But let me be honest with you – if your blog becomes just remotely popular you wont survive a standard out of the box WordPress deployment.


ElegantThemes
ThemeForest

Advertisement

Flexibility, ease of use, etc. comes at a very high price and in fact WordPress consumes enormous amounts of CPU and memory resources in order to respond to a single page request. The many string replacements in templates, multiple request to the database per request simply adds up and may take your entire site down if you hit the front page on fx. digg.com. Of cause you can just buy more hardware but as most bloggers don’t have budget for that it is important to get as much as possible out of the hosting plan you have. For good order I would like to state that my experience tells me that if you start getting moderate traffic ex. more than 2500 hits per day then you have grown out of any shared hosting solutions no mater how much you optimize your WordPress installation! I learned this the hard way and ended up changing to a Hybrid VPS at Wired Tree. After experiencing the regular frustrations using a shared plan at bluehost.com (servers down, slow, account closed because of too much CPU usage etc. ) is one of the best experiences I have ever had as a blogger, seriously! I will not cover hosting any further in this blog as it is a subject of it own. Let’s investigate some essential tips you can use to improve you WordPress performance.

Measure load time for future reference

Before we optimize anything I would recommend that you collect a few measurements that you can use as reference to see if your actions to improve performance have been worth the effort. Take multiple measurements and if you have the time and patience try making measurements over a few days with varying load. Also keep in mind that plugins and themes are software and in some cases they may not be optimized too well. I recommend that you go for using premium wordpress magazine themes for my sites, also to get the support.

Option a) Goto this on-line speed test tool (or use similar) and make a few hit on your site. On-line services like “iwebtool Website Speed Test” is one way to get a measure but I would recommend you to use a client side tool as well to get a better picture of your actual performance.

wp-performance

Option b) Use YSlow for Firefox to analyse your template complexity, size and load time from a realistic client. The load time and size can be found in the lower right corner. The Yslow Grade will be covered later in this post but is worth investigating!

wp-performance

Optimization Tips

#1 – Use serious caching (impact: very high)

There are many ways to do caching in WordPress. I’ll be honest with you – I have a favourite way to do it! If you are not using WP Super Cache Plugin already this is the time to make the change. It generates fully static html files when your pages are accessed for the first time and these are then served directly by Apache without processing PHP scripts on subsequent requests. When you read on to the other tips below you will know why this is so important. Providing static cached html files as you will do with WP Super Cache Plugin is the single most effective performance optimization tip I can give you BUT it is not without problems. Some pages will contain dynamically generated content and you want your updates to pages to be visible to you readers instantly. So when serving static cached html you need an intelligent and very well integrated caching engine and that is just what I believe WP Super Cache Plugin is providing.

wp-performance

WP Super Cache Plugin serve static pages only 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.

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. If you have plugins or other dynamic elements on your pages that need to be executed on the server on each request WP Super Cache provides a way to get around this. You can find a guide here in the section “How do I make certain parts of the page stay dynamic?”. You can also consider to use Javascript to load dynamic content fx. if you have a recent comments widget.

#2 – Optimize your template by reducing number of requests to the server, to the database and by lowering the overall load size (impact: very high)

Minimize simple unnecessary PHP queries. I’m a great fan of premium themes because they are so flexible and simple to adjust to your own needs. I also have found that flexibility is costly in terms of performance. To give you an example: searching for “bloginfo” in freshnews theme from Woothemes (the one I use) returns 283 results. What does this tell us? It tells us that functions like “bloginfo(‘name’)” and “get_bloginfo(‘template_directory’)” is used intensively. In some themes get_option() is also used heavily and will also be costly for rendering the page in the server. In the theme I have 961 of these… If you have cached your pages as described above this will only impact the first request where a page requested is not already cached. If user experience for all users (including the few who hit a non cached page) then it is highly relevant to see if you can get rid of any unnecessary PHP queries.

How to: ex. <?php get_bloginfo(’wpurl’); ?> just replace it with your wordpress installation URL.

Reducing requests to the server is key. Combining css files into one big css file can make a difference (One 50kb file loads a lot faster than five 10kb files). If you installed YSlow earlier to test performance you may have noticed that it also analyse the page and provide input on how you can optimize it. Having 17 Javascript files and 11 CSS files as illustrated below and a total of 75 components tells you that this page can be optimized! Looking at the Grade tab will help you understand what you can do to improve the load time.

wp-performance

There are several thing you can do and I would recommend that you read this article Best Practices for Speeding Up Your Web Site if you want to squeeze a few more milliseconds out of your load times. You will find concrete ideas for how to minimize number of requests to the server without compromising your design. Fx. combining CSS and Javascript into fewer files, using CSS Sprites to load fewer images etc. WP CSS is a plugin that may help you reducing number of requests to the server.

Load some Javascript in the footer. Some call it the The golden rule – CSS on top, javascript on bottom. In some cases you may want to put links to Javascript to the bottom of the page ie. just before </body>. Why? Because first priority is to render the page to the user and not downloading large scripts that are not instantly needed. This does not apply to all scripts and the key ones required by other scripts (e.g. libraries like jQuery) are still to be placed in the header. Also don’t move scripts that that provide Javascript functions used inline (e.g. a onclick=”doSomething()” as these would fail if the user interacts with elements before the function is available.

Make sure proper caching headers are set. Expires HTTP header can be set to specify a expire date on items downloaded from your site so that browsers won’t try to re-fetch images, CSS, javascript etc files that haven’t changed (this reduces the number of HTTP requests) and hence there will be a performance improvement on subsequent page views. You can learn more about controlling the expires HTTP header in .htacces in this article. How to Add Far Future Expires Headers to Your WordPress Site

#3 – Keep you database clean (impact: high)

Every database will, over time, require some form of maintenance to keep it at an optimal performance level. Purging deleted rows, resequencing, compressing, managing index paths, de-fragmenting, etc. is what is known as optimization. MySQL builds up what is called overhead and it will degrade your performance over time if you are not actively taking care of this. For good order you need to backup your database before the optimization procedure.

wp-performance

There are more ways to clean up overhead and repair your MySQL database. If you don’t have any database tools except for phpAdmin that most will have access to through their cpanel hosting admin interface. The phpAdmin way is rather simple and it is a tool you should be familiar with anyway. On the other hand it requires you to log into a separate tool and it would be much easier if you could do it all from WordPress – and you can. WP-DBManager is the perfect alternative and lets you do the database operation most WordPress user need including backups. It allows you to view current status of the database, optimize, repair, backup, restore, delete backup, drop/empty tables and run selected queries. Supports automatic scheduling of backing up and optimizing of database. Backing up and optimizing is as simple as clinking one button.

wp-performance

wp-performance

After running optimize all of your tables should have zero overhead as shown here. Check it once a month and run the job again when overhead starts building up.

wp-performance

If you are just like me – a bit lazy you may want to schedule all of this to happen automatically. In the DB Options tab you can configure this.

wp-performance

#4 – Proper image hosting can be important (impact: high)

Serving files to browser clients consume significant CPU resources on your web server. If your site is really busy you may free up a lot of CPU by moving images, CSS, JavaScript and other static files to a storage service like Amazon S3 Storage service. Try reading this step by step guide if this is something you believe your site will benefit from. Amazon S3 is not exactly free but it will serve your static resources fast and reliably. At the same time I will bet that your overall solution will be more scalable and the extra cost for Amazin S3 may be earned back by lowering the costs of your web server hosting.

wp-performance

#5 – Enable WP Built-in Object Cache (impact: medium)

WordPress introduced a file based caching of php objects in 2.x versions. It caches recurrently used php objects thereby reducing MySQL calls and improving performance.
It is currently disabled by default. You can enable it by adding the following to your wp-config.php:

// Enable the WordPress Object Cache:
define(ENABLE_CACHE, true);

This can give an immediate and measurable performance improvement. On the other hand it will increase the memory usage and you should be careful about using this on a shared hosting plan.

#6 – Turn off/limit/clean up post revisions (impact: medium)

Post revisions are important if you work together with others to create posts. It is also a good way to make sure that any changes to a post is documented and that something you have been working on for some time is not lost. On the other hand revisions can be a serious waste of database and server resources. Number of revision for a post can be found below the editing area.

wp-performance

To prevent the post revision from cluttering your database, it is an option to turn it off once and for all. You can easily turn off post-revision by adding the following line to the wp_config.php file (needs to be between the <?php and ?> tags.

define(’WP_POST_REVISIONS’, false);

This is that hard way and I would recommend another approach that prevents you from loosing any work if you fx. by accident save something wrong onto a document you put a lot of work into. You can keep a limited number of post revision saved per post. In your wp_config.php file, add the following line instead:

define(’WP_POST_REVISIONS’, no_of_revision);

and replace the no_of_revision by the number of revision copy you want to keep.

If you used revisions for a long time and have hundreds of posts with 10+ revisions each you may want to consider cleaning this up and using  the delete-revision plugin is a good option. It has not yet been fully tested with WP 2.8.6 but I have tried it as par of my preparations for this post and it worked fine.

wp-performance

#7 – Always keep WordPress and plugins up to date (impact: medium)

The developers maintaining WordPress are serious about their jobs and do a great job. Therefore it is recommended to plan an update  as soon as WordPress informs you of a new release. With regards to upgrading performance may be the least of you concerns. Security is usually the top priority so even if your site is fast you should not wait too long with upgrades. Make sure to follow the backup advice in #2 before updating WordPress. Using the WordPress build in updating feature have worked fine for me every time. Just make sure that if you make any changes to core files in WordPress (even though you should not really) then updating this way will instantly overwrite your changes. Backing up your files and keeping track up custom changes is important in that case.

When it comes to plugins you should be very careful. Installing and activating a plugin that is not downloaded from wordpress.org may be a direct thread to you WordPress installation. Also make sure you check if a plugin is well rated (3 or more stars) on wordpress.org before using it. Some plugins are written by inexperienced programmers that may not have thought carefully enough about security and performance. It is important to do some investigations before trusting a plugin and to monitor your site performance carefully when new plugins have been installed. Believe me I have tried to have my account closed in my early days as a blogger because I activated a plugin that went bananas after a few days of operations because it used bad bad practise when querying the database.

#8 – Remove unused themes (impact: minor)

There is no reason to have a lot of unused themes on the server, delete those that you don’t use.

#9 – Disable and Delete unwanted plugins (impact: minor)

If you have decided that you have no use for a particular plugin, deactivate them and delete them from your server. The more (unused) plugins you keep in your server, the longer it takes for WordPress to generate the plugin list and the higher tendency that it will slow down the loading time of your blog. Simplest way to delete a plugin is by using the “Installed Plugins” page. Any plugin that is not active will have a delete button. Be aware that deleting a plugin this way will not clean up the database tables it used.

#10 – Delete spam comments (impact: minor)

If you get a lot of spam comments you should not leave it in the database. Make sure you delete it as it comes in. If you want to use a plugin to make cleaning up easier I can recommend WP-Optimize. It allows you to delete all spam and unapproved comments and provides a lot of other useful optimization features.

wp-performance

#11 – Check your site for dead links (impact: cosmetic)

In the blogging sphere linking to relevant content on other blogs and websites is common practice. To keep your posts relevant and useful you should check frequently that the linked post/domain still exist and you are not left with a dead link.

The broken link checker plugin checks your new article for broken links as soon as it is published. It also scans your old posts when you are logged into the Admin page. Any broken links found are reported to you and you can choose to edit or unlink them from the posts. The first time I used this plugin I found more than 250 broken links on old posts.

wp-performance

References

WordPress Performance: Why My Site Is So Much Faster Than Yours – This post is worth reading if you want to go even deeper into the details of optimization. It covers things you can do with regards to MySQL Query Cache, PHP Opcode Cache, Apache httpd.conf, PHP php.ini and Linux Kernel.

 

{ 53 comments… read them below or add one }

Sudip February 4, 2013 at 5:39 pm

Can I use Google Page Speed Insights and GtMetrix to do the same thing?

Reply

Gift&premium August 4, 2012 at 5:49 am

iteresting

Reply

Gift&premium August 4, 2012 at 5:48 am

Great

Thanks you.

Reply

Alex June 5, 2012 at 10:30 pm

Nice round of optimization tricks. I found a couple of them very helpful. Another great plugin for performance optimization is Performance Optimizer plugin for Wordpress

Reply

Imraan May 26, 2012 at 8:18 am

Thank you so much for this exclusive post. I am using total cache but I am not getting much effective results.. do u recommend changing my plugin to super cache.. please help.

Reply

thiet ke noi that April 15, 2012 at 7:00 pm

Thanks for the tips…Very useful.

Reply

Jonny March 26, 2012 at 3:38 pm

I also suggest use Sumush.it wordpress plugin from yahoo. This will help to optimize your images and faster page load.
right now ! I think thas is no problem

Reply

Noi That Van Phong March 8, 2012 at 9:28 am

Thanks for the tips…Very useful.

Reply

Gennady February 27, 2012 at 12:00 pm

Great list, I’m surprised profiling PHP code with XDEBUG wasn’t mentioned, though. I’ve been able to catch huge slow chunks of code in many themes and plugins just by looking at cachegrinds.

Reply

Thiet ke noi that November 27, 2011 at 5:01 am

great. I use for My Blog and SEO.

Reply

Ana November 2, 2011 at 1:27 pm

Excellent Stuff…Quite Resourceful as well as helpfull. Blogs have always been the right medium for our expression and wordpress is the main among them. Thanks for sharing this great piece of information with us.

Reply

Thiet ke noi that October 18, 2011 at 5:46 am

Thank you! Excellent advanced tips! I didn’t pay attention to image hosting before. I think if hosting image in another host, it will save resource.
Thank again!

Reply

BoiteaWeb September 19, 2011 at 10:07 am

Hello
i’ll use this tips asap BUT i do not agree with the #2 point.
get_bloginfo() does a > get_home_url() which does a > get_option() which is naturaly cached by WordPress. So, i think if there is a gain, it is minor.

Thank you !

Reply

TemplatesRule.com March 10, 2011 at 1:36 pm

This post will be the asset for me. after reading all these steps i can better understand why some of our client have been complaining about the speed issue. thanks alot for such a great piece of help.

Reply

thiet ke noi that February 9, 2011 at 8:39 am

it’s good. i like it

Reply

thi?t k? n?i th?t February 9, 2011 at 5:31 am

I also learn about wordpress. thanks for sharing his knowledge

Reply

Brenda J. Wyche December 9, 2010 at 6:44 pm

Excellent info. Thank you.

Reply

alto club alvor November 18, 2010 at 2:50 pm

good advice ty

Reply

Haroun Kola August 21, 2010 at 3:08 pm

Great tips, I’m already doing most, but not all and I’ve learnt lots. My site has also been subjected to being switched off to over consuming resources on a shared hosting server and something that every serious blogger needs to be aware of :-)

Reply

Lars January 7, 2011 at 7:41 am

Agreed Haroun, and great that you learned new stuff!

Reply

Iulian Ionescu June 22, 2010 at 10:54 pm

Very cool post!! I am always looking to improve performance and there are some tricks here that I haven’t used yet…

Reply

HelloNingbo June 11, 2010 at 4:49 pm

THANK YOU for these great tips!

Although the “Broken Link Checker” plugin is quoted as impact: cosmetic, I think a website with “404 url not found” type of message looks quite unprofessional.
So following your advises, I downloaded this plugin and did correct/update quite a few links.

Thanks again and keep up the good work!
Paula

Reply

Deluxe Blog Tips April 19, 2010 at 10:48 am

The topic is old, but you write it in an exciting way. I’d like to use the W3 Total Cache instead of WP Super Cache. It has built-in function to minify CSS, JS files and even for using CDN.

Anyway, thank you very much for the comprehensive list :)

Reply

Telephone Answering Service March 20, 2010 at 10:30 am

I have never did or tried to build a wordpress design. But will have to try out with these tips!

Reply

Craig Mullins March 20, 2010 at 5:31 am

Any hosting plan should work, but I have those kinda numbers with both 1and1 and hostgator…

Reply

Themepremium March 19, 2010 at 10:46 pm

I also suggest use Sumush.it wordpress plugin from yahoo. This will help to optimize your images and faster page load…

Reply

tripwire team March 20, 2010 at 12:15 am

@Themepremium, thakns for the tip. I’ll check it out for sure.

Reply

Omer Greenwald March 9, 2010 at 2:24 pm

Excellent article. I use wp-minify to merge and minify javascript file and it really improved loading time. Its only down side is the fact that it loads the file at the top of the HTML instead of the bottom.
I also recommend using WP hacks and functions instead of some plugins as explained here http://www.webtechwise.com/speed-up-wordpress-blog-by-having-less-plugins/

Reply

tripwire team March 9, 2010 at 5:53 pm

@Omer, thanks for sharing your ideas and experience! I’ll check out the article you reference.

Reply

Humiliation Phone Sex UK March 9, 2010 at 11:34 am

You blog is eye-catching. I get pleasure from it. Thanks for sharing this knowledgable piece of writing with me.

Reply

Craig Mullins March 4, 2010 at 6:31 am

I’d just like to add that 2,500 page views is an insanely low number in my opinion to have to move to a dedicated or vps server…

I have 125,000 page view days on my $5.00 a month hosting plan with no problems whatsoever with wp super cache installed…

My guess is something else was going on or your hosting just plain sucked if you had to move..

Reply

tripwire team March 4, 2010 at 6:55 am

@Craig, sounds interesting. Are you saying that you have 125.000 page views per day or per month? What hosting are you using and what site are we talking about here?

Reply

Amber Weinberg March 2, 2010 at 9:23 pm

I tried Super Cache once and hated it. Not only was it annoying when I was updating code (which I do often) and I had to keep clearing it or completely turn off the plugin and redo the settings all over it. To me, I couldn’t notice a big difference and I hated not seeing the new stuff.

Reply

tripwire team March 3, 2010 at 12:03 am

@Amber, OK you’re right. Caching is annoying at development time! On the other hand if you have a heavy traffic website it is a must. You may not notice a huge impact unless the server is stressed. But once you start to hit the limits of what your hosting account cant deliver caching will be a way to keep costs down and ensure stable response times if you have a peak. Having super cache active when you’re not developing (could do that on an dev./test instance as well) is simply recommended… If you develop new code all the time….well then maybe you have special needs.

Reply

Dj Tukancheez March 1, 2010 at 10:01 pm

Lot of great tips!

I am gonna recommend this article, thanks for writing it.

Reply

tripwire team March 2, 2010 at 1:18 am

@dj, thanks a lot!

Reply

fræk date February 22, 2010 at 1:25 pm

This post is very nice to see and this is given to very good information.

Reply

jack January 25, 2010 at 8:57 pm

is it recommended to store repeating functions results in variables?

For example, if I have the_title() or the_permalink() functions appearing more than once in my index.php.
Will it be faster if I type and then echo $title1?

Reply

Page.ly January 13, 2010 at 10:34 pm

Great comprehensive post about speeding up response time for WordPress sites. I actually found some valuable nuggets of information. Thanks for sharing your wisdom.

Reply

Ovidiu December 11, 2009 at 5:29 pm

regarding #5 – Enable WP Built-in Object Cache (impact: medium) – as far as I know the Object Cache has been removed from Wordpress a long time ago, one needs an extra plugin for that…

Reply

Vlad November 26, 2009 at 12:07 am

Some one finally made me install WP Super Cache plugin. I don’t really like it, but I’m a scripting freak, and my functions file is impressive, so I need something to temperate me.

Reply

GingerWench November 25, 2009 at 7:41 am

Great post, recommended reading for anyone using WP. Thanks for sharing these resources!

Reply

Akhtar November 23, 2009 at 11:02 am

great tips for optimization, thanks for share!

Reply

viettel vt November 22, 2009 at 4:11 pm

Follow the instrution of Yahoo Yslow may help you in manythings :)

Reply

Xcobar November 22, 2009 at 4:04 pm

Great post.
Thank you for optimization tips – although I already knew and used some of the analysis made by you are excellent.
I also had my account on a shared-server “frozen” due to excessive use of server resources, and, after researching many options, I ended up with a VPS of WiredTree – that was the best decision I ever made: very good, changes the whole experience of using WordPress.
Greetings from Brasil

Reply

Roky November 22, 2009 at 1:48 pm

Thanx its very useful for me… im a new wordpress user… may be it help a lot :)

Reply

Lars January 7, 2011 at 7:40 am

Hope it helped and that your WP is running really fast!

Reply

designfollow November 22, 2009 at 12:43 pm

great

thank you

Reply

Vlad November 22, 2009 at 9:14 am

This post is really informative and interesting. Thanks for making it.

Reply

Tony November 22, 2009 at 3:02 am

Thanks for the tips…Very useful.

Reply

Lars January 7, 2011 at 7:39 am

You are welcome Tony

Reply

sachin January 30, 2012 at 6:37 pm

i lars

i am sachin , i want to creat my own e-commerce site using wordpress so i want your help for best codded themes for e commerce because i haven’t sound knowledge regarding coding so give me best codded themes free or premium any but best coded .

Thnaks and Regards
sachin

Reply

Lars January 30, 2012 at 7:52 pm

Hi Sachin. I haven’t had the opportunity to check the code quality in these themes but you could check out this post. http://www.tripwiremagazine.com/2011/12/best-wordpress-e-commerce-themes.html
I would recommend you to look for a theme that use a popular e-commerce plugin used by many other shops. This is in many cases better than a theme with build in shopping cart code only build for the one theme.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

{ 41 trackbacks }

Previous post:

Next post:


Web Analytics