• hello once again and a happy new year!

    i have a multisite network running and want to use a cache plugin but some sites are not allowed to be cached.

    so far, i only found “cache all or none”-plugins.

    w3 total cache, quick cache or wp super cache all can only be activated for the whole network, not on a per-site setting and there are no exceptions or settings to define that. hyper cache does not have network activation but if i activate it on one site it starts caching all others as well.

    any ideas which cache plugin would do the trick or if i’m missing a setting/option somewhere?

    thank you!

    bye,
    kwentin

Viewing 11 replies - 1 through 11 (of 11 total)
  • You’ll have to get your hands dirty writing some code but if you have a list of blog_ids then you can check if the current blog_id is in that list and define the constant DONOTCACHEPAGE and the page won’t be cached. Fire it off the init action.

    I think that constant is supported by wp-total-cache too so the same technique will work with that too.

    Thank you Donncha. I have the same perpetual question ?? although I’ve used your recommendation in the past for blog id exclusion I keep wondering when this is going to change and caching plugins are going to start truly supporting multisite needs like site-level enabling / disabling of caching.

    civr – do you have any suggestion for an interface? It’s simple to implement but doing it right could be hard.

    Text box for a new blog_id and a list of existing blog_ids with an X next to each to delete?

    Great question! Definitely many ways to skin that cat, eh? For our purposes we would want to install/activate and then only enable on a handful of specific sites with the highest traffic. I can also see how “bulk” enabling would be valuable, and I’m sure others would want to enable on all and then disable on a select few like for e-commerce or whatever.

    In terms of ideal interface, for your WPSC I think it’s already there – I’d just like the “enable caching” checkbox to actually work only on the individual site level. Instead of turning caching on/off, could that checkbox rather add or remove the current ID from wherever it makes sense to store the active ID list that gets checked when determining whether to cache a page or not?

    What would be really slick would be to add a column of checkboxes to the Sites table in Network > Sites with ajax postback that adds each selected ID to the stored active IDs. ??

    As a separate plugin and/or interface I think it would be best to store status whether disabled or enabled, and the UI could loop through all current sites, pull from wp_##_options their caching on/off status, represent as a checkbox, and let you toggle 1, multiple, or all, and save. Basically just ID | SiteName | Checkbox for caching enabled/disabled. As a separate plugin it would work with all caching systems that honored DONOTCACHEPAGE.

    Sincerely appreciate your time and everything you contribute to the WP community!

    Thread Starter KWentin

    (@kwentin)

    i’m sure my hands won’t get that dirty implementing the DONOTCACHEPAGE constant ?? I’ll look into it, thanks a lot for the advice and your contributions Donncha!

    Well, I added a Supercache plugin that adds a new column to the Sites page where you can disable or enable caching. It doesn’t clear out the cached files when you disable caching though. At least not yet!

    The development version should update in the next 20 minutes or so.

    NO WAY! You’re awesome D! I seriously didn’t intend / expect for you to jump on it that fast. I thought about taking a crack at it myself, but had no idea when I’d ever get around to it; and I figured that if you’re anything similar to as busy as I am (which I’m sure you are) it wouldn’t be fair to blatantly ask. ??

    This will make it practical for us to use Supercache again, so 1 million thank yous. I will take a look and let you know how it goes.

    OK. I have it up and running, and so far so good. Still a little tedious using the links one at a time, but WAY better than adding blog IDs to code somewhere. I think I’d prefer the reverse logic where all are disabled and only enable one at a time, but I see how the current implementation was probably the path of least resistance and hey I’m not complaining!

    A few tips for anyone else trying this:

    1) In case it isn’t clear, the code should go in a .php file inside the /wp-content/plugins/wp-super-cache/plugins folder

    2) I had to comment out the immediate check for
    if ( defined( 'WP_ALLOW_MULTISITE' ) )
    Multisite installations that were upgraded from WPMU might not have this set in wp-config.php (like us), and the condition was preventing it from running at all.

    3) You have to activate and enable caching initially for the column to show up on the Sites page.

    4) At first I was seeing mixed results and it seemed like it wasn’t working reliably. Use the built in Debug features! Turned out I was getting the notorious “No closing html tag. Not caching.” error. In this case not because of ob_start() but because I was enabling page compression in my theme like this:

    ini_set('zlib.output_compression', 'On');
    ini_set('zlib.output_compression_level', '1');

    Even with compression turned OFF in WPSC, and pages rendering correctly, it was still preventing WPSC from caching. So I commented those, turned on compression in WPSC and everything was great. Debugging log will report which sites are not getting cached because DONOTCACHEPAGE is set.

    Now, it would be a nice bonus to also have a comment written at the end of pages by WPSC when DONOTCACHEPAGE is set ??

    Anyway, thanks again Donncha! I have to tell you that I only revisited WPSC in the midst of a mini crisis and this has been an important part of a solution for some load-based instability that was crashing our server periodically.

    Where can I find explicit instructions for setting up DONOTCACHE? I am using Mingle Forums and obviously they are completely static with caching on…my url tree has /forums/ (https://www.site.com/members-only/forums/) and I entered that in as a string to be ignored:

    wp-.*\.php
    index\.php
    /forums/

    but they are still seemingly cached.

    Also tried checking the “Late init” box (while in legacy mode) and still cached.

    So my next step is to try DONOTCACHE but am unsure about defining constants?

    If your forum software loads a config file then add this code to that file:

    define( 'DONOTCACHEPAGE', 1 );

    and your forum should stay uncached.

    Donncha & clvr
    You are great.
    You helped me get over spending more time answering complains from clients trying to update their posts than on actual working ??

    Btw, anyway of getting the cache/don’t cache these types to be set differently on different blogs on a single multisite system?

    Again, thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘cache plugin for multisite: how to not cache all sites in network?’ is closed to new replies.