Let's say I want to share cached nodes with a common taxonomy term between users which share the same taxonomy term. Is this possible ? I want to share cached pages between users with the same taxonomy terms.

My approach so far is to find the requested URL (current_path()) inhook_authcache_key_properties_alter. If it is a node then compare its taxonomy terms with the user's taxonomy terms - this will involve querying the database- . If the taxonomy terms are the same then it will add the taxonomy term id to the $properties['roles'] array to generate a special key that later will be used by users with the same taxonomy term.

Comments

angel.angelio created an issue. See original summary.

znerol’s picture

This probably is not obvious from the documentation, but the cache key must not vary per path. The only safe thing to do in this situation is to unconditionally add the user-terms to the key properties. As a result a different key will be generated for each combination of taxonomy terms (and roles).

znerol’s picture

Component: Miscellaneous » Documentation
StatusFileSize
new1.36 KB

Attached is a patch with docs update. I tried to phrase it in a generic way but I'm not sure whether it is clear enough.

angel.angelio’s picture

StatusFileSize
new1.42 KB

IMO, I'd add @see authcache_builtin_cacheinc_retrieve_cache_page

It follows that key properties must not depend on factors other than
the currently logged in user or in some cases characteristics of the users
browser. Otherwise performance of the cache will suffer (i.e., the cache-hit
ratio will degrade)

So if the key does not change that often - I mean a 1 or 2 times per session- it might be "OK" to do it.

znerol’s picture

So if the key does not change that often - I mean a 1 or 2 times per session- it might be "OK" to do it.

Frankly I'm not quite sure.

znerol’s picture

Category: Support request » Feature request
Status: Active » Needs review

This patch should be included into a release regardless of the open question.

Status: Needs review » Needs work

The last submitted patch, 4: share_cache_between-2634028-4.patch, failed testing. View results

znerol’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB

Careful with hand-editing patches ;)

znerol’s picture

Title: share cache between taxonomy terms » Better docs for hook_authcache_key_properties

  • znerol committed b03b2be on 7.x-2.x
    Issue #2634028 by znerol, angel.angelio: Better docs for...
znerol’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.