Getting WP Super Cache / W3 Total Cache to work with bbPress 2.0
Is there anything I need to do to get the aforementioned caching plugins to invalidate topic pages, forum indexes and so forth when a new reply is posted?
I’ve tried both 2.0.2 and the latest bbPress plugin version from svn and as it stands, posting a new reply does not clear the topic page (or any other forum pages) from the cache so you and nobody else sees your replies.
Just wanted to check if it’s currently a bug / feature or I’m missing something obvious!
Assuming it’s a static page cache that isn’t being invalidated? Seems odd the post and meta update wouldn’t flush the object and query cache automatically.
Yeah, that’s right. Agreed, I assumed it would work too so figured I should check if I was missing something. Will have a look and see what’s going on.
So I can get both of these cache plugins to work by hooking into a few actions in bbPress and invalidating the post (which may be a topic or forum) and any ancestors (which would be a topic / forum in the case of a reply) by doing the ‘edit_post’ action on each post. There are a couple of edge cases still to deal with (like subscribing to a topic that needs your user page invalidating) that I’ll have a look at this evening.
Only real thing I don’t have an answer to is the freshness count. If you view a forum and the last topic was posted 1 minute ago then you come back an hour later and refresh the page you’ll see the cached page stating that the last topic was posted 1 minute ago rather than an hour ago. I could go with the fixed date approach but it’s not as neat.
Just wondering about this.
Is W3TC “safe” to use with bbPress 2.0?
If there are places where bbPress is not busting the cache properly, I’ll need your help to figure out where and why. bbPress currently relies heavily on WordPress’s API’s to do this for us. bbPress runs very few manual queries of its own, and new or edited posts should be busting the cache automatically.
As well as being cache-friendly, this solution would allow the possibility of locally updating, so if you switch to another tab in the browser and switch back a few hours later, the “1 minute ago” can change to “3 hours ago”.
JJJ: Ok, I’ll put together the list of actions / filters I’ve used to get cache invalidation working when I get back to my home machine (then hopefully you can say “no no no, all you needed to do was this…”). Is this forum post the best place or a trac ticket?
CiaranG: I was thinking along the same lines and shouldn’t be hard to do with a bit of jQuery I’d hope!
I disabled the cache when I added bbPress to the site I am running, but desperately miss it (speedwise).
This kind of solution would allow me to reinstate the cache and everything would fly along nicely again!
JC: Anything further on this? I’m running this on a production site and have just noticed caching issues with W3 and bbPress. I would love to leverage what you’ve already figured out before I hack through it!
I didn’t understand from your reply do you want to add hooks that’ll purge cache made by caching plugins inside a core?
Problem with page cache and bbPress (outside relative times) is that when something new is posted, parent post type(s) isn’t cleared (for example, when you post a reply, topic’s and forum’s pages aren’t refreshed until cache expires).
I’m working on a simple plugin that effectively fires:
do_action( 'edit_post', $id );
on any topic, forum, etc. when edited, created, trashed, spammed, split, etc to flush the topic and forum out of the cache.
I’ve almost got it working and am just getting trashing / untrashing to work then will put it up somewhere to let others work on it. While it’ll work in my case where I’ve not got a bbPress aware theme it may need some tweaking / improvements for all cases.
In the meantime, I’ve gone for a) low cache time – 60 minutes, plenty enough to have good performance though, and b) disable cache for logged in users only. This seems to be a satisfactory solution to me.
I also found, under heavy load, that Super/Total cache didn’t help a great deal, while Quick Cache had a massive impact. YMMV though of course.
@johnconners – Any updates on your plugin? Page caching would be a HUGE help for large BBpress sites like mine.
Been a bit swamped with work lately so I’ve not had a chance to finish it up yet (there are still a couple of use cases where certain pages aren’t flushed from the cache). However my approach has been to try and hook into the fewest places possible and just do the ‘edit_post’ action on whatever topic / forum / page needs flushing.
My current work in progress, in case anyone else has more free time just now than I do, is here:
Hopefully in the next week or two I’ll have some time to finish it myself if nobody else does in the meantime. Also, any thoughts on a better implementation – let me know!
Just wanted to check if it’s currently a bug / feature or I’m missing something obvious! <a href=”http://www.anytimefitnesslocations.net/
Could WP Super Cache tags do the job?
How do I make certain parts of the page stay dynamic?
There are a few ways to do this, you can have functions that stay dynamic or you can include other files on every page load. To execute PHP code on every page load you can use either the “dynamic-cached-content”, “mfunc”, or “mclude” tags. The “dynamic-cached-content” tag is easier to use but the other tags can still be used. Make sure you duplicate the PHP code when using these tags. The first code is executed when the page is cached, while the second chunk of code is executed when the cached page is served to the next visitor. To execute WordPress functions you must define $wp_super_cache_late_init in your config file.
This code will include the file adverts.php and will execute the functions “print_sidebar_ad()” and “do_more_stuff()”. Make sure there’s no space before or after the PHP tags.
include_once( ABSPATH . '/scripts/adverts.php' );
include_once( ABSPATH . '/scripts/adverts.php' );
To execute the function “function_name()”:
<!--mfunc function_name( 'parameter', 'another_parameter' ) -->
<?php function_name( 'parameter', 'another_parameter' ) ?>
To include another file:
<?php include_once( ABSPATH . 'file.php' ); ?>
That will include file.php under the ABSPATH directory, which is the same as where your wp-config.php file is located.
<!--mfunc date( 'Y-m-d H:i:s' ) -->
<?php date( 'Y-m-d H:i:s' ) ?>
@JohnConners any news? I know a lot of people who’d love to know more about any new findings you might have made.
@moderators please get this spammer out of here.
Likely unknown issues surfacing, or bbPress becoming more complex over time and W3TC interoperability not being specifically tested.
Just wish to report that I have confirmed to my satisfaction that W3 Total Cache is not working with BBPress — using latest versions as of this date, January 8, 2013. I installed both in the last week.
I have an active forum thread going on my website and as I observe it carefully, I can see that new replies are not generating page refresh for the topic. So, an anonymous user coming would not see latest replies. So, either there is an incompatibility or W3 just isn’t working right, which is possible — see this comment on that plugin:
I am liking BBPress but lost some confidence in W3 total when it brought down my site fully on a minify error yesterday (nice enough to send me an error message but then everything went white and had to uninstall and reinstall to complete the fix). Now realizing that it is incompatible with BBPress, I’m going to have to pull it and try to run without caching for a while and see how it goes.
Thanks for sharing @will-brownsberger . So it’s been 3 weeks, how are you doing? There’s also a mention of a fix in that thread you linked to, but I’m not sure if it’s been applied yet.
We’re on a constant lookout for bbPress-compatible plugins to use on jmonkeyengine.org. It could really save us from a very costly hardware/hosting investment.
W3 Total Cache working at 188.8.131.52
Just curious if bbpress is compatible yet with this version of w3 total cache.
Just installed W3 total cache yesterday and it seemed to work. When I tried logging in through a sidebar widget it did not work. Disabled page caching and it works again.
So I guess there must be an exclude setting for the forum area that could make it work. Will try this this evening.
- You must be logged in to reply to this topic.