Support » Plugin: WP Super Cache » How to enable cache for subscribers and

  • Hi, Is it possible to enable cache only for subscribers and unregistred users?
    And disable for other groups: administrators, editors, authors etc.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Saša

    (@stodorovic)

    Hi @texnoguy,

    You should create custom WPSC plugin which could do something like this (to create and manage them, you’ll need extensive knowledge of both PHP and WordPress actions).

    Anyway, if you create plugin then each user will have separate cache file (wp-cache file instead of super-cache file for anonymous visitors). You could try to use option “Late init”, but I think that isn’t possible to get user role before serving file (even with later init).

    Other possibility (which isn’t recommended) is to use option Make known users anonymous so they’re served supercached static files, but can’t exclude specific user roles from “anonymize process”.

    Regards,
    Saša

    texnoguy

    (@texnoguy)

    Hi, thank you for youк answer!
    Yes, I use option Make known users anonymous so they’re served supercached static files, because there are a lot of registred users on site. It seems work perfect. WPSC caches content for all users exclude admin. But we have need to exclude editors too. I search for documentation of WPSC but slill no idia how to do that.

    Saša

    (@stodorovic)

    You should find other unique way to exclude these users (by IP address, query parameter, UserAgent string or maybe – additional cookie). Function wp_supercache_cache_for_admins removes cookie wordpress_logged_in regardless to user role because it’s too early to get any user info.

    Maybe it’s possible to create WPSC plugin which will set custom cookie (eg. wpsc_disable_cache) if user role is editor (at login and unset at logout). If WPSC plugin detects this cookie then WPSC could disable caching. It’s an idea, but I don’t know is it doable or no.

    seanhelmes

    (@seanhelmes)

    I also really would like to have it so all subscribers are served cached files. Only admins, editors, authors and contributors should have non-cached sessions.

    seanhelmes

    (@seanhelmes)

    If anyone has a solution please let me know

    Saša

    (@stodorovic)

    I’ll try to make WPSC plugin in next couple weeks if you want to test it.

    texnoguy

    (@texnoguy)

    It will be great, I’ll be glad to test it.

    seanhelmes

    (@seanhelmes)

    Same here!

    Saša

    (@stodorovic)

    I think that development of WPSC plugin requires some changes in WPSC. For now, I’ve created two feature requests: [Feature Request] Improve option – “Make known users anonymous so they’re served supercached static files.” and [Feature Request] Add option – “Cache pages with custom cookies”.

    I’m working on PR which will better handle cookies. You could follow github issues for more details.

    Related to “excluding users”, I’m thinking that the best way is to extract username from logged in cookie. On this way we don’t need to add new cookies. Also, it’s safe because it only prevent caching. Before storing cache file, WPSC should use WP API(which is available because WP is fully loaded) to detect users and it seems as the best approach for now. We can add array of excluded users in wp-cache-config.php – something like this:
    $wp_cache_excluded_users = array( 'admin', 'editor1', 'editor2', 'userxyz', 'testuser' );

    It isn’t perfect if you want to exclude a lot of users, but I’d guess that’s small list and probably it’s doable. Please send your feedback.

    @stodorovic any update on this request?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to enable cache for subscribers and’ is closed to new replies.