How to improve BuddyPress speed and performance
Jul 25 2011 - 6 MINS READ

The combination of WordPress, BuddyPress and all of your plugins can sometimes lead to a slow website. What follows is the ultimate guide to speeding up your BuddyPress site. In combination, the techniques described below will dramatically improve your page load speed. Some of these methods are easy to implement while others are more difficult. Just do what you feel comfortable with.


The Basics

Stay up to date

WordPress and plugin authors regularly release updates which you can download by going into Dashboard > Updates in your WordPress dashboard. Many of these updates provide speed improvements and you should get into the habit of downloading updates fairly regularly. Always back up your files and back up your database before performing updates! On the rare occasion that something goes wrong, you will save yourself a huge headache by having backed up your website first.

Limit plugin use

WordPress has over 15,000 plugins available. With all of these plugins, it’s tempting to try out every plugin that peaks your interest. However, every additional plugin you install will need to request information from your database and the cumulative effect of having dozens of plugins is that your site will slow down. Use only the plugins that you actually need. Try to remove the rest.


Caching Methods

Caching is definitely the most effective method for speeding up your website. Below is an excellent explanation of what the word “caching” actually means, by Tutorial9.

“Each time you visit your blog, WordPress will go through a sometimes lengthy process to build everything you see. First it will process the PHP code which will make numerous calls to your database and finally output HTML for your web browser to display. On some blogs this could happen between 20 to 200 times per page! WordPress has often been criticized as slow but we can change that by enabling caching.”

“If you enable caching only the first visitor will go through this entire process. The caching mechanism will save the data and then serve every subsequent visitor the final result. Thus speeding up WordPress by a huge factor. Trust me, you want it and your visitors will thank you for using it.”

Important: You have to be very careful when caching with BuddyPress, as much of the content is dynamically generated and must stay fresh. Follow our guide and you will be okay:

General Caching

Install the Hyper Cache plugin. Carefully follow the instructions below to avoid problems with your BuddyPress setup…

Hyper Cache is specifically written for people who have their sites on low resource hosting providers. This plugin will make an enormous speed improvement and is recommended instead of other similar plugins such as WP Super Cache or W3 Total Cache. It will work better with BuddyPress and is quite simple to set up.

Under the “Configuration” settings panel, set the “Cached pages timeout” to just 1 minute.

By default this plugin will cache all of your site’s pages, including your BuddyPress-specific content like activity posts and forum posts. This is not good, as your BuddyPress content is constantly updated and needs to remain fresh. To fix it add the following lines into “URI to reject” in the “Filters” settings panel of Hyper Cache:

/forums/
/groups/
/members/
/activity/
/blogs/
/messages/
/register/
/activate/

Add any other base URI’s that you want to reject. For example, if you have a section with /photos/ in the base URI and users are uploading photos into this section, you would want to add /photos/ to the list.

Database Caching

Install the DB Cache Reloaded Fix plugin. This plugin caches every database query on your website and reduces how many times your site needs to access the database, thus speeding things up. You should be fine using the default settings.

Image Caching

Neither of the methods outlined above will cache the images used throughout your site. Caching your images will help speed things up as well. I am not aware of a good plugin for this, so you will have to do it manually.

If you know how to edit files via FTP, open up your preferred FTP program and make sure “hidden files” are viewable. Find a file called “.htaccess” in the root folder of your website and open it. Add the following to the end of the file to cache site images for one month:

# Image and Flash content Caching for One Month
<FilesMatch “.(flv|gif|jpg|jpeg|png|ico|swf)$”>
Header set Cache-Control “max-age=2592000”
</FilesMatch>


Database Optimization

Your actual database can get filled with old junk that bogs it down, such as post revisions that have collected over time. You can clean out all of the unused content from your database to reduce its size.

Install the WP DB Optimizer plugin. The plugin optimizes your database tables with one click. To use it, just go to Settings > Optimize Database and it will instantly optimize it for you. I recommend getting into the habit of occasionally returning to this plugin and cleaning your database.

Install the Better Delete Revision plugin. Then go into Settings > Better Delete Revision. Click “Check Revision Posts”. It will display all of your post revisions, and you may be surprised to find hundreds of them! From this screen you can delete them all.


CSS Minification

This one is for experienced developers only. The stylesheets that come with BuddyBoss (in the _inc/css/ folder) are uncompressed and are thus quite long. A browser needs to read through all of them and this adds to page load speed. Theme authors do not release themes with minified CSS as normal users would have a difficult time figuring out how to edit the stylesheets, but if you are comfortable with code this is a great technique.

First, back up all of your stylesheets so you have the source files to return to later. I personally just duplicate the files and rename them, such as “default-source.css”, and then edit the original file.

Then use this CSS compressor: http://tools.w3clubs.com/cssmin/

Enter all of the code from your stylesheet into the top box, “crunch” it, and then paste the resulting minified code back into your stylesheet, copying over all of the uncompressed code. Your CSS will be reduced from thousands of lines to just 1 big block of CSS.

You can do the same trick with your JavaScript files with this JS compressor: http://jscompress.com/


Reliable Hosting

If you are on a shared hosting plan, it might be the case that your web host is “overselling” and there are too many websites sharing the same server as yours, putting a bottleneck in the pipeline. Switching web hosts should be considered a last resort, as it can be a real pain. But if all else fails this may be your best option to speed up your site. If you have a high traffic site you might consider getting a dedicated server, which will host only your site on one server. These are expensive, often $100/month or more.