Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I want to exclude certain roles (of which I am sure they do not alter output) from the authcache key, so the same cache is used as users that have the same roles except those certain roles. For example roles that give access to certain admin pages which aren't cached.
Just to make sure, is it sufficient to implement hook_authcache_key_properties_alter()?
function hook_authcache_key_properties(&$properties) {
$properties['roles'] = array_diff($properties['roles'], array('admin reports', 'moderator files'));
}
Thanks in advance.
Comments
Comment #1
casey CreditAttribution: casey commented#1258730: Users with multiple roles using same authcache is somewhat related, but in 7.2 "authcache_key_generator" is only available for anonymous users.
Comment #2
znerol CreditAttribution: znerol commentedFor authenticated users, you can alter the key-properties. Try something like this:
Disclaimer: I just left my bed and you should not expect that this code is bug-free. But it should get you an idea on how it might work.
Comment #3
casey CreditAttribution: casey commentedThanks!
Comment #5
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthis is another great example of modifying for certain roles:
https://www.drupal.org/node/1258730#comment-6906900