The MU forums have moved to WordPress.org

Modifying WP-Cache for WordPress MU (105 posts)

  1. suleiman
    Member
    Posted 10 years ago #

    i did install the sk2 plugin Q, and I've also got 1.2.1 running.

    it only happens on some blogs, which is the odd part.

  2. lunabyte
    Member
    Posted 10 years ago #

    Strange Sul.

    I'm running ajax comments as well, and I don't think it's an issue. I'll have to double check.

    Is the sk2 plugin in addition to the tweak of rewriting that one function and adding to phase2?

    I'd "think" that leaving a comment would trigger a cache refresh, but maybe not since it's ajax comments. I will try to look into this later on today, once I get some other coding out of the way.

  3. Leftblank
    Member
    Posted 10 years ago #

    First of all I'd like to thank you guys for this topic, it's been helping me a lot with my own setup.

    I do have one question left that I haven't seen answered yet; when disabling WP-Cache in one blog using the 'Options -> WP Cache' page will disable it on every blog; is there any workaround available to prevent this from happening, besides disabling the option in some way?

  4. suleiman
    Member
    Posted 10 years ago #

    leftblank, as far as i know, the only way to do so would be to give each blog it's own config file.

  5. lunabyte
    Member
    Posted 10 years ago #

    Pretty much you only want to enable this for blogs that need it.

    Wrap the add_action at the bottom of wp-cache.php in an is_site_admin() check.

    Then in your main wp-config make an array of domains you want to enable it for, and then check http_host against the array. If there's a match, set the defined constant for wp-cache.

  6. lunabyte
    Member
    Posted 10 years ago #

    Hey Quenting, check this crazy thing out...

    So I get digging and start tweaking this out, so that only the heavier traffic blogs are being cached.

    Note to other readers, this is a good idea or else you will end up having "any" subdomain that is accessed end up getting a directory created for it. Even if that site on your install doesn't exist.

    So anyway, I put an array in my wp-config file, run a check, define and enable WP_CACHE for a match, etc, etc.

    Great, it's working.

    I go into a blog that isn't cached, nothing in the footer, and all is well, right?

    Nope, it wasn't.

    I get into my box to clear out all the cache directories, so that the unwanted ones aren't still sitting there. Well, all is good. I hit the handful of blogs I wanted cached, the directories are recreated, and it's looking fine.

    Then I run and do something, come back to double check everything is still OK, and there were directories for additional sites that weren't specified.

    WTH, right?

    So I do some digging, and even put the same array into the wp-cache-config file, and put an extra clause in the if for making the directory.

    It still was doing it.

    I keep digging.

    To make a long story a little shorter, it was because of the actual plugin file. The wp-cache.php in mu-plugins.

    So, I remove it, clear the extra site cache directory, and it's all good.

    Even though wp-cache wasn't defined, the file in mu-plugins was still prepping the "site" in case it was turned on.

    So, I ended up just taking out the actual plugin file completely, since it's only good for admin stuff anyway, and as we discussed earlier it isn't really needed.

    So, as a note to anyone who limits it to certain blogs, either open the plugin file (wp-cache.php) and comment out the part where it checks for the cache dir and makes it if it doesn't exist, or just take the file out all together since it really isn't needed.

  7. quenting
    Member
    Posted 10 years ago #

    it sounds weird indeed, although i can't relate to it because the part where it checks for the directory existing is in the config file for me.
    I ended up pushing back those files to their own directory anyway since the moment i decided not all blogs would have it enabled, just in order for the files not tog et reparsed for every other blog.

  8. lunabyte
    Member
    Posted 10 years ago #

    Well, that's what I'm talking about though.

    The directory creation is in the config file. But, if the plugin file (wp-cache.php) is in MU plugins, whether it's enabled or not for a blog, there is a function in there that will automatically create the individual blogs cache directory if it doesn't exist. It shouldn't normally affect anything, because it would be in the plugin directory of a normal blog. But, being in mu-plugins, it will auto-execute.

  9. Farms
    Member
    Posted 10 years ago #

    Have spent a lot of time over the past few days on this thread :)

    The good news is that I *think* I've got everything running smoothly, and am hoping to package it all up with 1.2.3 instructions about how to install.

    The bad news is I've found a bug to do with password protected posts (popular in education), basically they just don't work:

    http://www.mc-kenna.com/2006/wp-cache-password-protected-pages-problems/
    http://mnm.uib.es/gallir/posts/2007/01/31/963/#comment-21117

    There's gotta be a fix though, perhaps using .htaccess to exclude password protected posts from being cached, or a wp-cache hack itself... any ideas?

    Cheers, James

  10. donncha
    Key Master
    Posted 10 years ago #

    Farms - try this. Look in wp-cache-phase1.php for the line:
    if (preg_match("/^wordpress|^comment_author_email_/", $key)) {

    Change that to read
    if (preg_match("/^wp-postpass|^wordpress|^comment_author_email_/", $key)) {

    I haven't tested it, but by taking a quick look at post-template.php I see that the password protected posts feature uses a cookie that starts with "wp-postpass". Clear your cache after making the change above.

    It'll make your caching slightly less efficient if you have password protected posts but nobody will notice.

  11. donncha
    Key Master
    Posted 10 years ago #

    Just tested it on a WP site and it works :)

  12. andrewbillits
    Member
    Posted 10 years ago #

    Thanks for that. I can knock it off my to-do list for the day :)

    Thanks,
    Andrew

  13. lunabyte
    Member
    Posted 10 years ago #

    I haven't looked into this yet, but I've noticed that new posts and certain other modifications aren't causing the cache to be reset any longer under 1.2.5(a).

    Might be me, I dunno. Just thought I'd throw it out there since James dug up the topic.

    Examples: New comments, new posts, deleted comments, etc.

    I haven't diagnosed it yet, but I will be over the next few days.

  14. wep
    Member
    Posted 10 years ago #

    2) admin.php

    if($_SERVER['REQUEST_METHOD']=='POST') {
    do_action('my_update_plugin');
    }

    add in what line?

  15. dbasulto
    Member
    Posted 10 years ago #

    Good to hear about updates on this :)

About this Topic