Caching BuddyPress

Modified on May 7, 2014

You can get noticeable performance improvements by enabling Object Caching, which will improve page load times for not only BuddyPress, but many other plugins, themes and WordPress core itself.

Caching Methods Explained

Page Caching

When people think of caching, “page caching” is usually what comes to mind first. Unfortunately page caching is not a practical solution if you have BuddyPress enabled. With page caching, when a page is requested a fully assembled HTML file is generated and then served to subsequent users who visit that page (until the cache expires), dramatically reducing hits to the database. Due to the dynamic nature of BuddyPress, page caching would cause content to go stale, defeating one of the core purposes of BuddyPress – live interaction between users. You could theoretically cache pages for logged out users only. But once they are logged in your BuddyPress content would go stale and dynamic elements within the Toolbar, like Notifications, would stop updating until the page’s cache expired.

Object Caching (recommended)

Even though we are not able to cache finished pages, we can still cache a lot of the data that is used to assemble those pages via “Object Caching”. BuddyPress is built to be able to take advantage of Object Caching when you have a persistent caching plugin enabled, such as W3 Total Cache.

WordPress has an API (a set of functions) for Object Caching that allows developers to cache data used by their code. By default, WordPress allows for a form of Object Caching but its lifetime is only for a single page load. If you have a persistent caching plugin installed, you can make the object cache persist longer than a single page load which will reduce the amount of requests to your server and improve page load speed. This is what we’ll be setting up in the next section.

How to enable Object Caching

APC – (private server) (recommended)

If you are hosting your site using our recommended server setup, you can simply contact your web host and request that they install APC on your server (it’s free) and then it will be available to you as a very fast method for Object Caching. Generally you cannot install APC on a shared hosting environment. APC stores the cached values in RAM, which is why I recommend at least 2GB of RAM for ideal server performance.

Once your web host has confirmed that APC is installed and working, you will then need to enable it for WordPress with a plugin. My recommended method is with the APC Object Cache Backend plugin. This is not a true plugin, but rather a “drop-in” file. As such, you do not actually activate the plugin. You just need to copy the object-cache.php file into your /wp-content/ directory. You don’t even need to upload the actual plugin. That’s it! As long as you have APC installed on your server and have placed the file correctly, APC-powered Object Caching should now be enabled and you should begin seeing performance improvements. To confirm that it’s working, you can type this into your browser while logged in as an admin: . It should show APC Object Cache as a drop-in.


You can also enable APC caching using the W3 Total Cache plugin, at Performance > General Settings, under “Object Cache”. If you’re already using W3 Total Cache this may be the preferred method. If you’re not using W3 Total Cache already then I recommend the above plugin as it only requires one file to work!

File caching (shared hosting)

If you are using a shared hosting plan, APC will not be an option and you will likely be limited to file caching, where the cached values are stored in files on your web server. This will ideally result in performance gains, but there is a chance that it could actually result in a negative performance impact if your hosting environment cannot handle it. This is another reason as to why I recommend getting a good server setup and then implementing a proper caching method like APC. But if you are limited to shared hosting, you can try file caching and see if it works for you.

The best method is to install W3 Total Cache. After installing and activating the plugin, go to Performance > General Settings, and then navigate to “Object Cache”. Check the box to “Enable” the object cache. Under “Object Cache Method” it will probably only offer “Disk” as you are on shared hosting. You will see grayed out options for APC, eAccelerator, and other various options that could theoretically be installed on a private server setup. Click “Save all settings” and you have now enabled Object Caching, with the cache saving files to your disk.


After enabling the Object Cache, you can navigate over to Performance > Object Cache to configure the cache options as necessary.

Add comment

E-mail is already registered on the site. Please use the Login form or enter another.

You entered an incorrect username or password

Sorry, you must be logged in to post a comment.


by Oldest
by Best by Newest by Oldest

Could you make a tutorial about the best settings for W3 Total Cache and Buddypress? (preferably in shared hosting)

Profile photo of Michael Eisenwasser

With W3 Total Cache, the most important setting is what I have written above in the "File caching" section. In W3TC, go to Performance > General Settings, and then navigate to “Object Cache”. Check the box to “Enable” the object cache. Under “Object Cache Method” it will probably only offer “Disk” as you are on shared hosting. Click “Save all settings” and you have now enabled Object Caching, with the cache being saved into files to your disk.

The rest of W3TC can be mostly ignored or turned off. You don't want any page caching with BuddyPress. You can sync assets to a CDN in W3TC settings if you want.


I tried setting up APC on my Cloud VPS 2x 2.0GHz CPU


but it actually slowed the site down. Seemed to caused a few second delay before page load. My host installed it. Here is the setup. Wonder if you see anything wrong with the settings? Maybe they don't know how to properly tune for Buddypress.

Thanks Ray

PHP Version 5.3.28

Version 3.1.7

APC Debugging Disabled

MMAP Support Enabled

MMAP File Mask no value

Locking type pthread mutex Locks

Serialization Support php

Revision $Revision: 307215 $

Build Date Dec 16 2013 14:38:29

Directive Local Value Master Value

apc.cache_by_default On On

apc.canonicalize On On

apc.coredump_unmap Off Off

apc.enable_cli Off Off

apc.enabled On On

apc.file_md5 Off Off

apc.file_update_protection 2 2

apc.filters no value no value

apc.gc_ttl 3600 3600

apc.include_once_override Off Off

apc.lazy_classes Off Off

apc.lazy_functions Off Off

apc.max_file_size 1M 1M

apc.mmap_file_mask no value no value

apc.num_files_hint 1000 1000

apc.preload_path no value no value

apc.report_autofilter Off Off

apc.rfc1867 Off Off

apc.rfc1867_freq 0 0


apc.rfc1867_prefix upload_ upload_

apc.rfc1867_ttl 3600 3600

apc.serializer default default

apc.shm_segments 1 1

apc.shm_size 32M 32M

apc.slam_defense On On

apc.stat On On

apc.stat_ctime Off Off

apc.ttl 0 0

apc.use_request_time On On

apc.user_entries_hint 4096 4096

apc.user_ttl 0 0

apc.write_lock On On

Profile photo of Michael Eisenwasser

Are you running BuddyPress 2.0+ ? BP made significant improvements in how it handles object caching with 2.0. Also make sure you followed the step of adding the drop-in APC plugin in WordPress, otherwise the object cache is not even being used. It should speed up the site immediately. If not, I'm not sure off hand.


I have the latest versions of everything and the drop in shows up fine. Maybe a plugin conflicting or something. I'll have to do some further testing in my dev site. I pretty happy with the site speed without it so not a big deal.

I'm looking forward to BuddyBoss version 4, seems to be very snappy in it's beta form



Hi, great article.

I have some question. Did enable database cache with buddypress will be working good?

Profile photo of Michael Eisenwasser

Glad you like the article. Yes, it should work.


Got this installed with no issues, good tip. Seems to have sped up some. Next to head to your list of improvements. I'm getting terrible pagespeed scores right now. That's not too bad though... I need to find a solution to spam on the registrations. I'll look through your site for something.

Profile photo of Michael Eisenwasser

Glad you found it helpful. You might want to watch this video, it will help quite a bit:

Also, ask your host to enable GZIP if you haven't already. Makes a noticeable difference.


I'm running my own server, so I think I have to do this... In reading they are saying that Mod_Deflate is the new version and gzip is for older Apache?


Strangely I guess it's already on... via this nice tester. I have Google's Apache Pagespeed mod installed.

Profile photo of Varun Dubey

Cool, glad you have that working. Those online testers are helpful. I've used this one in the past, I'm sure they're all the same:


I've heard that its not worth using fastcgi with APC, or it causes problems? Excuse my lack of knowledge on the subject. Do you recommending using CGI instead? Thank you!


So did a lot of research. Just FYI for everyone, if you are using PHP 5.5 or later then APC has been replaced with a built in Zend OpCache which is fantastic. APC is no longer supported.

Put this code in your php.ini file:



Then download OpCache Dashboard plugin.

Works like a charm.

Profile photo of Michael Eisenwasser

Brandon, Thanks for posting this info.


Hi i use opcode from php5.5 yes it works great, how about if i use elastic cache which is Memcache from Amazon since my site hosted on Amazon Cloud, and set W3 Total Cache settings on object caching to memcached will that work with the dynamic part of the site and other php functions will be compiled still by Zend OpCache ?

Profile photo of Michael Eisenwasser

The main guiding principle here is to make sure you are caching PHP but not HTML. As soon as you start caching HTML you lose the dynamic part of the site. As for your specific PHP caching solution, I'm not sure about that specific setup, I would suggest contacting your hosting provider.


Hi michael I have a question for you, OK when using php 5.6 or php 7 that has opcache buitlt in as standard using w3 total cache doesnt detect opcache so even though i have a dedicated server that is now running php 7, all of the vps and dedicated settings are greyed out and only disk cache is available? when i was using php 5.3 apc was available and fully installed but support for it has gone from later versions, so how do we get total cache to use the inbuilt opcache that is bundled and turned on by default with php 5.5, 5.6 and 7?

surely if we have opcache installed and working then clicking on disk enhanced etc will degrade performance not enhance it?

Profile photo of Michael Eisenwasser

This tutorial is a little outdated now. I would suggest not using any disk caching from a plugin. Just have your server admin install Zend OpCache on server. It should work automatically with WordPress/BuddyPress. This may help to confirm it's working :