Support » Plugin: Gator Cache » Need help with Gator's hook

  • Hello, i need to allow ‘create cache’ for users that are logged_in, how use the new hook thing ?

    cant it work only for a specific role ?
    if not how or where do the customisation ?

    that way :
    only a certain role can create the cache. (not logged_in user, cant)
    then i chose in setting what roles will recieve it.
    i add Ajaxize plugin to keep certain function still dynamic

    and voila i have a site that is partly cached for logged in user but have some dinamic stuff !

    https://wordpress.org/plugins/gator-cache/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter JibsouX

    (@jibsoux)

    UP ^^

    Plugin Author GatorDog

    (@gatordog)

    In the GatorCache settings you can set certain roles to be treated as regular visitors as far as the cache is concerned. Their content will be cached and served as an anonymous visitor. Of course, if you have any type of personalized content for the role in question, you would not want to do this.

    The hook ‘gc_cache_user_content’ is a way to further refine this. When using this hook you should not cache any role by default. Then you can use any criteria to base caching user content. By default caching user content is false, so, if for some reason you want user content to be cached you’d do something like this:

    add_filter('gc_cache_user_content', function($doCache){
        global $user;
        return isset($user) && 'Fred' === $user->first_name;
    });

    This would cache user content for all users with the first name of Fred.

    Thread Starter JibsouX

    (@jibsoux)

    Tx but the thing i am trying to do is :

    Simple subscibers role can create cache when they visite my site, then with the core setting in gator cache (users tab) : add subscibers to deliver them the cache
    (add some role in this tab don’t allow them to create cache but simply recieve caching content that simple non logged in user have created)

    then with the plugin Ajaxize turn some content to ajax loading that way all the personalized content of users is still personalized.

    i want to do that because my website is subscibers area only so by default no cache is created..

    Plugin Author GatorDog

    (@gatordog)

    Think I see what you’re trying to do – you want the page cache to be generated from subscribers content. The plugin will not do this at all without using the gc_cache_user_content hook.

    For this to work, you have to do two things:

    1) From the “Cache Rules” tab of the GatorCache settings, make sure “Enabled Hooks” is activated under advanced settings.

    2) Then in your code somewhere, such as your theme’s functions.php, you’d need to use the gc_cache_user_content hook. Here is an example for the subscriber role

    add_filter('gc_cache_user_content', function($doCache){
        global $user;
        return isset($user->roles) && in_array('subscriber', (array)$user->roles);
    });

    Thread Starter JibsouX

    (@jibsoux)

    Yep that’s what i’m trying to do ! you rock dude !
    and one more question, with that setting it desactivate the capabilitie to create some cache for not logged in user ?
    If not can i desactivate it ?

    Because there will be a conflict betwin those 2 cache (not logged in cache and logged in cache created by subscribers) since the output page is not the same if logged in or not, but it’s the same url :

    – Not logged in user consult like : http://mysite.com/page1/
    Output = “you must be logged in + custom login/lost password form”

    – Logged in user consult like the same page : http://mysite.com/page1/
    Output = the content of the page.

    Plugin Author GatorDog

    (@gatordog)

    The same cache is served to all users. However, there are different caches for mobile and ssl. So what you’d like to have is a seperate cache for logged-in users?

    Thread Starter JibsouX

    (@jibsoux)

    in a way : the thing is to access the site an user got to :

    1 : http://mysite.com/
    That Output = “you must be logged in + custom login/lost password form”

    there a cache is created is’n it ?

    2 : after he logged in : same url : http://mysite.com/
    that Output = the content of the page.

    but there a previous cache (1) was created when the user was not logged in no ?
    so it deliver the cache not the (2) > “the content of the page.”

    or am i wrong ^^?

    That is why if i’m right there will be a conflict and the cache delivred will be the cache created by the non logged in user (1)

    or the use the hook to activated the capabilitie for subscibers to create cache override the capabilitie to create cache by not logged in user ?

    so if not, is it possible to desactivate the capabilitie for not logged in user to create the cache ?

    Do you know what i mean ?
    (sorry i’m french ^^)

    Plugin Author GatorDog

    (@gatordog)

    You would need two caches, one for logged in, one for non-logged in users, to segregate the content. Currently this is not available. You should not cache logged in users pages, they will be served to visitors as well. So you should remove or comment out code that allows this.

    I will take a look at supporting multiple caches, it already supports seperate caches for ssl, mobile, etc.

    Thread Starter JibsouX

    (@jibsoux)

    aahhhh okey !
    So i have in mind 2 improvement
    1 : if hook is activate allow admin to disable the capabilitie of creating cache for not logged in user
    2 : your proposition to allow multiple cache following the roles

    One for not logged in
    One per role (hook)


    so now is it possible to desacivate not logged in user capabilitie to create cache ?

    or i wait until you have release the improvements in the next version 🙂

    Plugin Author GatorDog

    (@gatordog)

    Yes, if you currently just want to create cache content for the logged in user, you could define DONOTCACHEPAGE for non logged in users, probably on the WP init action. However, it would still serve the cache that’s created by logged-in users to non-logged in users. So you would probably want to wait for an update.

    Thread Starter JibsouX

    (@jibsoux)

    Tx dude i will be patient ^^

    Thread Starter JibsouX

    (@jibsoux)

    By the way one question : there will be a support for buddypress not bbpress one day ?
    ^^ i know that buddypress is pain to cache because of all the activities from the user but i was just wondering 😀
    peace !

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Need help with Gator's hook’ is closed to new replies.