The MU forums have moved to WordPress.org

1 2 3 4

Modifying WP-Cache for WordPress MU (105 posts)

  1. earcos
    Member
    Posted 17 years ago #

    I have WPMU installed and running on my server, I'll be using it for a comercial blog network in spanish which is very popular. One of the blogs have a lot of visits (45,000+ a day) so wp-cache is a must.

    According to this post on this very same forum, you have to modify wp-cache WP-Cache to add $blog_id to the cache key otherwise cache files for different blogs will stomp on each other.

    I tested (an unmodified version) of WP-Cache and that's just what happens, it shows the cached version of another blog.

    So I was hoping someone has already been through this and show us where to modify the wp-cache to make it work with WP MU.

    Thanks a lot!

  2. badlagar
    Member
    Posted 17 years ago #

    Im interested too... ;) someone that have wp-cache in wpmu?

  3. boetter
    Member
    Posted 17 years ago #

    I'm also listening here. Very interested indeed, I've got some traffic issues aswell!

  4. drmike
    Member
    Posted 17 years ago #

    I hope someone's looking as well. :)

  5. earcos
    Member
    Posted 17 years ago #

    I sent an email to Ricardo Galli author of the plugin regarding this issue, when he replies me, I'll let you guys know. If you have any ideas in the meanwhile, would be nice.

  6. badlagar
    Member
    Posted 17 years ago #

    Thanks Eduardo!

  7. earcos
    Member
    Posted 17 years ago #

    Ricardo answered me, told me he'll be looking into it, maybe it's not that hard. I'll keep you posted.

  8. helmi
    Member
    Posted 17 years ago #

    thanks for letting us know, earcos. I would also be interested in that.

  9. drmike
    Member
    Posted 17 years ago #

    Agreed. Thanks.

    I haven't looked at WP-Cache so I couldn't tell you. Sorry.

  10. Ovidiu
    Member
    Posted 17 years ago #

    I just downloaded it from here: http://mnm.uib.es/gallir/wp-cache-2/
    because I had a look at the changelog and it seems it is now wpmu compatible.

    I tested it in plugins folder and it seems to work, I'll try it right now in the mu-plugins folder and post again.

    ###edit###

    It gave me some errors like this:

    Warning: main(/var/www/web5/web/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /var/www/web5/web/wp-settings.php on line 90

    Fatal error: main(): Failed opening required '/var/www/web5/web/wp-content/advanced-cache.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/web5/web/wp-settings.php on line 90

    AND I had to add this line:

    define('ENABLE_CACHE', true); to my wp-config.php file but I already had this line there:
    define('WP_CACHE', true);
    so I am pretty unsure if this is right...

    still if used from plugins folder it seems to work, sitewide... now we just need to mod it so that only the admin/blog owner can enable disable and change settings

  11. lunabyte
    Member
    Posted 17 years ago #

    http://mu.wordpress.org/forums/topic.php?id=1343&replies=22#post-7237

    Adding define('ENABLE_CACHE', true) turns on object caching for MU.

    define('WP_CACHE', true) is for the actual plugin.

  12. quenting
    Member
    Posted 17 years ago #

    lunabyte, could you explain the difference between wp-cache and mu caching ?

  13. lunabyte
    Member
    Posted 17 years ago #

    The one in MU that is already there is object caching, but how that relates and compares to the wp-cache plugin I'm not real sure of at the moment.

    From the post referenced above, it does mention that it used to be enabled by default, but now it is not.

    I haven't dug too deep into that part of the source to get a good grasp on it, so maybe someone else that has can elaborate more.

  14. Ovidiu
    Member
    Posted 17 years ago #

    me again :-)

    anyone else using the wp-cache plugin?

    I am using the latest version 2.0.22 and have the following strange probs.

    I am using it from the plugins folder, as I thought I'd let users decide whether they want to activate it or not, for testing I activated it in my testblog, then went to the main blog to activate it also but it was also activated => if any blog activates or deactivates this plugin it effects everybody who has the plugin activated. if you go to wp-cache options, click list cached pages, you'll see all cached pages sitewide...and I just noticed you see each page twice !?-)

    besides these probs its working fine.
    I have been thinking if it wouldn't make sense to mod the plugin so its options can only be accessed by the sitewide-admin so that I decide to use the plugin for all blogs or not, and only I can fiddle with its options? if we could get it working from mu-plugins folder this would be nice.

    please give some advice, share your thoughts maybe I am completely wrong?

  15. lunabyte
    Member
    Posted 17 years ago #

    Have you brought it up to the plugin author?

    They may be very interested in your test data. ;)

  16. Ovidiu
    Member
    Posted 17 years ago #

    I thought I post here first, see if others using the plugin have the same problems...

  17. lunabyte
    Member
    Posted 17 years ago #

    True, and I agree. But they still might like to know over there. ;)

  18. suleiman
    Member
    Posted 17 years ago #

    so Ovidiu, you were able to get this to work in your mu plugins folder or not? I'm going to give that a go and see how it goes.

    Also with respect to where you add the define(wp_cache) segment, do you know what file that is?

    EDIT: saw it, wp-config.php, thanks.

    Thanks.

  19. Ovidiu
    Member
    Posted 17 years ago #

    no I am still stuck with the probs mentioned 3 posts above.... will try to debug tomorrow.

  20. pumpkinslayer
    Member
    Posted 17 years ago #

    Changes are written directly to the config file so when anyone changes them, the file gets changed.

    Still testing it out

  21. suleiman
    Member
    Posted 17 years ago #

    pumpkinslayer, one strategy would be to simply not show the admin page unless the user is a site admin. I've done this hack on a few of my plugins and it involves putting a simple if statement before the execution of the code that displays the page. The code is here:

    get_currentuserinfo();
    if( is_site_admin() )

  22. suleiman
    Member
    Posted 17 years ago #

    pumpkinslayer, one strategy would be to simply not show the admin page unless the user is a site admin. I've done this hack on a few of my plugins and it involves putting a simple if statement before the execution of the code that displays the page. The code is here:

    get_currentuserinfo();
    if( is_site_admin() )

  23. lunabyte
    Member
    Posted 17 years ago #

    What's the get current user info for?

    is_site_admin() doesn't need it. ;)

    "Changes are written directly to the config file so when anyone changes them, the file gets changed."

    Hmmm. Maybe writing a file to their files directory instead would be more appropriate. Provided you want to allow the user to change something.

    If not, than putting the action call that adds the link for it to the submenu inside an if check for is_site_admin would be fine. Of course you'd have to add another if check inside the actual admin function(s) for the same thing, and if they aren't a site admin run die, or something.

  24. Ovidiu
    Member
    Posted 17 years ago #

    I think writing a config file to their directories would be better, as oposed to only letting the site admin handle the cacheing - I mean would you want to edit each blog and set caching on? and would you want to check each blog if they have functions in their blogs/templates that should not get cached? things like showing random stuff, would always get cached,...

  25. suleiman
    Member
    Posted 17 years ago #

    hmm....good point ovidiu. and thanks for the tip lunabyte!

  26. lunabyte
    Member
    Posted 17 years ago #

    I know for me, I'm keeping wp-cache reserved for higher traffic blogs. But that's just me. For the "little guys", there isn't much need for it.

  27. Conmiweb
    Member
    Posted 17 years ago #

    How can install it without errors?Thanks

  28. Ovidiu
    Member
    Posted 17 years ago #

    ok, as a first try I changed this line

    $wp_cache_config_file = ABSPATH . UPLOADS . 'wp-cache-config.php';

    inside wp-cache/wp-cache.php
    to have wp-cache save a config file for each blog, this works, I'll go ahead and test if it still mixes up the caches of different blogs.

    found out I had to also change this line:

    if( !@include( ABSPATH . UPLOADS . 'wp-content/wp-cache-config.php')

    in wp-cache/wp-cache-phase1.php

    I have not found more yet, but in this phase after changing it it does not work for me, strangely it does not cache anything...

  29. Conmiweb
    Member
    Posted 17 years ago #

    How can I know if it's caching o or not?

  30. Ovidiu
    Member
    Posted 17 years ago #

    I opened a post or page severall times, using different browsers and then had a look at the source code. wp-cache will add something like: "served fro mcache" or similar to the end of the source code if the page was cached.

    also you can go to the options of wp-cache and check the list of pages in cache.

1 2 3 4

About this Topic