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.[exec]$filestr = file_get_contents(‘http://www.tripwiremagazine.com/googleadsensebelowmoretag.inc’);
echo $filestr;[/exec]
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.
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!
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 Super Cache Plugin serve static pages only to:
- Users who are not logged in.
- Users who have not left a comment on your blog.
- 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.
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.
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.
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.
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.
#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.
#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.
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.
#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.
#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.
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.
Lars started tripwire magazine back in January 2009. He is really passionate about web design, web development and loves to look into new technologies, techniques, tools etc. and to write articles for his readers.
Thanks for the information you shared, I will visit more website
Can I use Google Page Speed Insights and GtMetrix to do the same thing?
iteresting
Great
Thanks you.
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
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.
Thanks for the tips…Very useful.
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
Thanks for the tips…Very useful.
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.
great. I use for My Blog and SEO.
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.
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!
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 !
[…] Most Essential Tips for Improving Response Time of Your WordPress Blog – tripwire magazine. […]
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.
it’s good. i like it
I also learn about wordpress. thanks for sharing his knowledge
[…] this article today on “Most Essential Tips for Improving Response Time of Your WordPress Blog” good read with some useful tips. Most useful of which was the plugin Broken link checker. […]
[…] Most Essential Tips for Improving Response Time of Your WordPress Blog. Porady dotycz?ce przy?pieszania dzia?ania naszej […]
Excellent info. Thank you.
good advice ty
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 🙂
Agreed Haroun, and great that you learned new stuff!
Very cool post!! I am always looking to improve performance and there are some tricks here that I haven’t used yet…
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
[…] Most Essential Tips for Improving Response Time of Your WordPress Blog | tripwire magazine […]
[…] http://www.tripwiremagazine.com/2009/11/optimize-wordpress-for-professional-performance.html […]
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 🙂
[…] Most Essential Tips for Improving Response Time of Your WordPress Blog […]
[…] TripWireMagazine: […]
I have never did or tried to build a wordpress design. But will have to try out with these tips!
Any hosting plan should work, but I have those kinda numbers with both 1and1 and hostgator…
I also suggest use Sumush.it wordpress plugin from yahoo. This will help to optimize your images and faster page load…
@Themepremium, thakns for the tip. I’ll check it out for sure.
Social comments and analytics for this post…
This post was mentioned on Twitter by kicauan: Most Essential Tips for Improving Response Time of Your WordPress Blog – http://su.pr/1kVa0h…
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/
@Omer, thanks for sharing your ideas and experience! I’ll check out the article you reference.
You blog is eye-catching. I get pleasure from it. Thanks for sharing this knowledgable piece of writing with me.
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..
@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?
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.
@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… Read more »
[…] Go here to see the original: Most Essential Tips for Improving Response Time of Your WordPress Blog | tripwire magazine […]
Lot of great tips!
I am gonna recommend this article, thanks for writing it.
@dj, thanks a lot!
This post is very nice to see and this is given to very good information.
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?
[…] See the rest here: Most Essential Tips for Improving Response Time of Your WordPress Blog | tripwire magazine […]
Great comprehensive post about speeding up response time for WordPress sites. I actually found some valuable nuggets of information. Thanks for sharing your wisdom.
[…] Official Link […]
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…
[…] This post was mentioned on Twitter by Simon Vreeman and Coen Jacobs, ‡ ??????? ‡ . ‡ ??????? ‡ said: Most Essential Tips for Improving Response Time of Your WordPress Blog – http://su.pr/1kVa0h […]
[…] Official Link […]
[…] Official Link […]
[…] here to read the rest: Most Essential Tips for Improving Response Time of Your WordPress Blog … Comments0 Leave a Reply Click here to cancel […]