Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching for specific user roles #42

Open
Geschan opened this issue Aug 16, 2016 · 7 comments
Open

Caching for specific user roles #42

Geschan opened this issue Aug 16, 2016 · 7 comments

Comments

@Geschan
Copy link

Geschan commented Aug 16, 2016

It would be useful if the cache can be enabled/disabled for specific user groups.
For example in a WooCommerce shop: cache enabled for customers (as cart, checkout and my-account aren't cached anyways), cache disabled for admins and all other roles (especially roles with activated admin-bar).

@Zodiac1978
Copy link
Member

You can use the option "No cache generation by logged in users" for that.

If you need more control there is already a hook for that: cachify_skip_cache

Here is an example:
https://gist.github.com/Zodiac1978/5c95a4f70daa73171e4462bbe817759b

@Geschan
Copy link
Author

Geschan commented Aug 16, 2016

The option "No cache generation by logged in users" is for all users, so not what I suggested.

I'll have a look at cachify_skip_cache but it would be a nice feature to add in a future version at the configuration page.

@swissspidy
Copy link
Contributor

Thanks for your input @Geschan!

So basically you suggest turning the "No cache generation by logged in users" checkbox into an option where you could say e.g. "Only enable caching for users with role author or higher" . Does that sound about right?

@Geschan
Copy link
Author

Geschan commented Aug 16, 2016

Basically yes.
A WooCommerce customer is also a logged in user, but there is no need of excluding him from the cache.
In most cases he will get the same content as the anonymous user does - except of the cart, checkout, my-account and some API requests which are already excluded by the DONOTCACHEPAGE constant or other rules.

@Zodiac1978
Copy link
Member

So basically you suggest turning the "No cache generation by logged in users" checkbox into an option where you could say e.g. "Only enable caching for users with role author or higher".

If we enable cache generation for user roles with an active admin bar this would be a problem.

Even if we check is_admin_bar_showing there could be Edit links inside the theme which shouldn't be cached.

@swissspidy
Copy link
Contributor

Yeah enabling caching for logged-in users would mean not showing the toolbar or any Edit links to them as if they were normal visitors.

To improve performance for logged-in users, we should think about integrating #31. Simply put, an object cache is a a key-memory store which gets populated so WordPress doesn't have to call the database dozens of times.

@Geschan
Copy link
Author

Geschan commented Aug 23, 2016

There might be a problem with caching of regular users, but I'm rather talking of WooCommerce customers and similar with no rights to change any content on the site at all (except of writing comments).
It would be a good feature for an "expert configuration" for people who know what problems the caching of logged-in users might cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants