• Trying to use WP-Cache 2 with some dynamic portions of the page. I am using the mclude commands, but am running into confusion on exactly what is allowed to go into the PHP file that I am including.

    The problem is that my site has a “welcome back…” statement on it, plus the ads disappear, depending on a person’s privledges. So, ideally, I would have fully cached pages ONLY when the person is not logged in at all. If they ARE logged in, then everything stays fully dynamic.

    Unfortunately, it seems WP-Cache is an all-or-nothing, which means its going to cache regardless whether the user is logged in. And that means I have to look at making portions of the page dynamic.

    So, in the PHP file that I try to include, I have a call to get_currentuserinfo(). That halts execution and makes the page fail to load, guessing because it cannot find that function. But, without running a function to query for user privledges, I can’t welcome anybody back or make anything dynamic because I don’t know who the user is.

    So, I guess these are my questions:
    (1) Is there a way to leave the entire site fully dynamic if the user is logged in at all, but only raw users get a cached version?
    (2) In using Wp-Cache 2, is there a way I can execute external functions (functions which are part of the WP core) inside the file which is included using mclude?

    Thanks for ANY help. I’ve literally wasted 3 hours on this this afternoon.

Viewing 1 replies (of 1 total)
  • In response to (1) and bearing in mind the fact that I’m not 100% clear on whether you’re using WP-Cache or WP-Super-Cache.

    WP-Super-Cache will allow you to do (1) without messing with the source code of the plugin itself. WP-Cache2 does not (as far as I can see) allow for this.

    Example of a WP-Super-Cache plugin to completely disable caching for logged-in users…

    .../wp-content/plugins/wp-super-cache/plugins/nocache-logged-in.php
    <?php
        while ($key = key($_COOKIE)) {
            if (strpos($key, 'wordpress_logged_in_') !== false) {
                $cache_enabled = false;
                break;
            }
            next($_COOKIE);
        }
        reset($_COOKIE);
    ?>

    With WP-Cache2, you could hack the wp-cache-phase1 source code in a similar fashion since upgrades to the plugin aren’t much of an issue.

    Insert into wp-cache-phase1.php @ Line 10 or thereabouts...
    
    while ($key = key($_COOKIE)) {
        if (strpos($key, 'wordpress_logged_in_') !== false) {
            $cache_enabled = false;
            break;
        }
        next($_COOKIE);
        }
    reset($_COOKIE);

    With respect to (2), the short answer is ‘No’. When the cached content is pulled from the cache, it’s very early in the WordPress load sequence and there’s not much available to play with.

Viewing 1 replies (of 1 total)
  • The topic ‘Super Cache and Dynamic Include’ is closed to new replies.