Warmed items not a cache hit if using complex/multiple cache contexts/variations per view mode

Created on 13 January 2023, about 2 years ago
Updated 25 January 2023, about 2 years ago

Problem/Motivation

Hi there. I'm trying to get this working on Omnipedia, but Drupal still seems to have cache misses even after enqueuing this and running it via Drush. I've tried it both only with published nodes and all nodes, and both authenticated and anonymous users. We have a rather complex set up with many cache tags and a few cache contexts, so I don't know if this is necessarily a bug with this module, but from looking at the code, it doesn't seem account for multiple cache contexts for a given view mode. In short, it's likely rendering everything correctly, but what gets stored in the render cache is likely not being matched to most or all of our nodes.

Steps to reproduce

Have different cache contexts (e.g. user permissions hashes) for entity view modes. Run this module's warmer. Try visiting one of the warmed entity in the warmed view mode in your browser, e.g. a node page. Drupal will likely still render it anew, potentially taking a few seconds for a really complex page.

Proposed resolution

We pre-render complex diffs between two nodes on using our own custom Warmer plug-in while also figuring out all the different possible cache variations via core's user_permissions_hash_generator service, and then use the core an account_switcher service to temporarily switch to another user for rendering each cache variation. Maybe a similar technique could be used for this module to take cache contexts into consideration?

Remaining tasks

See previous heading.

User interface changes

Potentially some additional form fields if the cache contexts warrant some configuration?

API changes

None I think?

Data model changes

Technically no, since the core render cache already supports cache variations/contexts.

✨ Feature request
Status

Postponed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada ambient.impact Toronto

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States devkinetic

    ...some sort of automatic building of contexts, but then that begs the question of how you would determine which ones to render in and which are not relevant so that turns into another big problem.

    This make me think about providing a plugin that provides the custom contexts. Just do it in code. The UI could be modified to detect these plugins and simply enable them. Then all we would need on the warmer plugin side would be a method to process the contexts for the relevant records, and add the "extra" items into the queue for processing.

Production build 0.71.5 2024