WordPress is a free and open source CMS for blogging (which is suitable, via add-ons, for e-commerce use). And besides blogging, WordPress has the advantage of being already SEO-friendly, as it is easily crawled by search engines. What’s more, WordPress has already done 80% of the SEO for you.
So what can you do to increase your SEO points? One thing you can do is improve your blog performance. Visitors and search engines love fast-loading blogs. So how can you improve your WordPress blog performance?
1. Cache database queries
You need to cache database queries. A WordPress blog will perform more than 50 queries to the database for 1 post visited (this value is relative, depending on your design and data), so caching this query will increase your WordPress blog performance and also reduce your server load. The WordPress Plugin to help you to cache sql queries is Db cache reloaded fix. It is easy to install, and easy to configure. I use it, and I very much recommend it.
Update:db cache reloaded doesn’t work with WordPress 3.1. I create a patch for WordPress 3.1, it available in WordPress plugins repository: Db cache reloaded fix.
2. Optimize images
Reducing image size will save you download time and bandwidth. For example, let’s say you need to show an image which is only 100×150 pixels in size, but the image you are hosting is actually 200×300 pixels in size. Optimizing this image will save you money (indirectly) and increase your blog performance. There are some online and offline tools to minimize this image. I use Google PageSpeed tools; I find them adequate.
3. CSS Sprites
The term “sprites” originates in old school computer graphics and the video game industry. The idea was that the computer could fetch a graphic into memory, and then only display parts of the image at a time, which was faster than having to continually fetch new images. The sprite was the big combined graphic. CSS Sprites is pretty much the same theory: get the image once, shift it around and only display parts of it, thus saving the overhead of having to fetch multiple images. Use SpriteMe to sprite your images.
4. Optimize themes
Examine your themes and replace dynamic code with static code. For example:
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> //Change To:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
As you can see from the code, the bloginfo(‘html_type’) function will get data from the database. By replacing those functions, you will save some queries to the database. So go to your themes folder, find that kind of code, then replace it with static.
5. Minify CSS, JavaScript and HTML
Minifying static files like CSS, JavaScript and HTML will reduce the file size. This will reduce download time and save bandwidth. One of the best plugins to do this is Wp-Minify. WP-Minify will detect all your CSS and JavaScript files, combine and then minify them. It also has a facility to do html page minify. Besides minifying static files, WP-Minify also boasts a cache mechanism for those files. Minifying these static files will have great benefit, and considerably increase your blog performance.
6. Page cache
Besides minifying static files, page cache also has great impact on your blog. There are a lot of WordPress cache plug-ins; the three best are WP Super cache, W3 Total Cache and Hypercache. I use Hypercache as it’s compatible with Wp-Minify and db cache reloaded.
So I have combined these three plugins to cache queries, minify static files, and cache pages. As a result, my blog performance has become four to five times faster, with reduced CPU load and memory used.
7. Use GZip compression and let the browser cache your files
With GZip compression, the server will reduce the page file size before sending it to the browser. Again, a smaller file size means reduced page loading time and increased performance. And besides using Gzip, you may need to ask the browser to cache your static files in local storage, so it won’t download them over and over. Just add these lines to your .htaccess file:
#################################################### # CONFIGURE media caching # # Header unset Expires # Turn on Expires and set default expires to 3 days ExpiresActive On ExpiresDefault A259200 # Set up caching on media files for 1 month <filesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$"> ExpiresDefault A29030400 Header append Cache-Control "public" # Set up 2 Hour caching on commonly updated files <filesMatch ".(xml|txt|html|js|css)$"> ExpiresDefault A604800 Header append Cache-Control "private, must-revalidate" # Force no caching for dynamic files <filesMatch ".(php|cgi|pl|htm)$"> ExpiresDefault A0 Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0" Header set Pragma "no-cache" # ##################################################### <filesMatch ".(js|css)$"> SetOutputFilter DEFLATE mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_keep_workfiles No mod_gzip_can_negotiate Yes mod_gzip_add_header_count Yes mod_gzip_send_vary Yes mod_gzip_command_version '/mod_gzip_status' mod_gzip_min_http 1000 mod_gzip_minimum_file_size 300 mod_gzip_maximum_file_size 512000 mod_gzip_maximum_inmem_size 60000 mod_gzip_handle_methods GET POST mod_gzip_temp_dir /tmp mod_gzip_item_include file .html$ mod_gzip_item_include file .php$ mod_gzip_item_include file .pl$ mod_gzip_item_include file .rb$ mod_gzip_item_include file .py$ mod_gzip_item_include file .cgi$ mod_gzip_item_include file .css$ mod_gzip_item_include file .js$ mod_gzip_item_include mime ^application/javascript$ mod_gzip_item_include mime ^application/x-javascript$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^httpd/unix-directory$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include handler ^server-status$ mod_gzip_item_include handler ^server-info$ mod_gzip_item_include handler ^application/x-httpd-php mod_gzip_item_exclude mime ^image/.*
8. Reduce use of plugins
Plugins, plugins, and plugins. Too many plugins will reduce your blog performance. Just choose the plugins that are most suitable for you, and throw away any plugins that you don’t really need. Plugins can be the root of WordPress error issues. Choose your plugin carefully, and test it first. Related post: Should You Upgrade Your WordPress Plugin or Not?
9. Use Google App Engine
Google, the best and largest search engine on earth, has Cloud computing technology to host your web applications. Google App Engine is Cloud computing technology for developing and hosting web applications in Google-managed data centers. You can host your static files on Google-managed data centers which are distributed all over the world. This facility is available as a free CDN (Content Delivery Network). Read this post to use Google App Engine to host your static files.
10. Choose hosting carefully; a VPS might be necessary
Now we come to hardware issues. If you have done everything above, but your server is slow, then that will mess up the whole thing. Choose your hosting server carefully, and if you have more than 10k visitors per day, then a medium VPS might be needed. If you host your blog in share hosting, then you don’t need to do server optimization, the administrator has already done it for you. But if you have a VPS, then it should be configured correctly for WordPress blogs. Read this post to choose your hosting server.
Really solid walkthrough! I was not aware of WP-Minify and I was recently trying to sketch out how to build that in my head. Thanks for the tip!
Thanks Josh 🙂
mas ivan, db cache reload fix itu compatible dengan wp multisite gak ya?
thanks
db cache reloaded fix nya cuma patch dari db cache reloaded sebelumnya. Jadi kalau yang sebelumnya support yang ini juga pasti support.
thanks mas
If you have done everything above, but your server is slow, then that will mess up the whole thing.
mas mau nanya nih soal hyper cache.
hyper cache ini lama ya kalo bikin cache file nya?, soalnya 1 hari ini cuma 5-10 file di cache. apakah memang begitu?, atau ada settingan yang kurang?.
All the tips mentioned here to improve our wordpress blog performance were very usefull…..
Ivan,
You're missing the closing IfModule tag on your gZip code. Causes 500 errors as is.
Other than that, great tips and great plugin for caching.
Thanks.
i will fix it, thanks for notifying me.
Wpisz tutaj swój komentarz.
It's great tutorial. Thanks!
if i use that htaccess file i get a 505 error
the site won’t work
@zerocool.marius add </IfModule> at the end. Looks like wp editor mess it up.
now it works..
i’m using db cache reloaded fix and this htaccess…
hope the site wil be faster
@ivankrisdotcom @zerocool.marius
Combine images into CSS sprites
this is what it says to page speed
i saw that u have a small tutorial, but still i can’t do it 🙁
@zerocool.marius Cool. Let me know your experience 🙂
@zerocool.marius CSS sprites need a little bit CSS skill. You can combine your small images with SpriteMe and configure your css to use that sprite images.
@ivankrisdotcom
well that’s the hard part for me 😀
I installed Wp-Minify and on pagespeed online still it tells me i need to minify java html and css
@zerocool.marius have you try to clear your cache? post your link here.
http://pagespeed.googlelabs.com/#url=www.animelovers-fansub.com&mobile=false
@zerocool.marius I look into your website. But if found there are some css and js hard coded to your header.php. Wp-Minify works if you use wp_enqueuestyle and wp_enqueue_script.
hey
i’m using WordPress Total Cache and on Yslow it tells me to put javascript to the bottom
well.. the java is from this plugin
w3tc/min/c7945d28.19dd81.js
but how do i put it to the bottom ?
i can’t find anything
@zerocool.marius it si because W3TotalCache minified it. I believe that there is a setting to put it at the bottom.