Attachments need user cache context

Created on 3 May 2023, over 1 year ago
Updated 12 May 2023, over 1 year ago

Problem/Motivation

Hi, I'm not using the module so haven't been able to confirm, but I did a quick look at the code and it seems to me it might be missing a cache context? IIUC currently it embeds per-user data and adds a user cache tag, which ensures the cache gets cleared if the user entity's updated. But it doesn't indicate to the cache that different users have different data.

Steps to reproduce

Proposed resolution

You could add a user cache context. I think by default that would make the page uncacheable, see https://www.drupal.org/docs/drupal-apis/cache-api/cache-contexts#s-uncac... , but you could add a lazy builder.

I was thinking an alternative to having a user cache context that would have less impact on the page's cacheability might be to simply detect if a user is logged-in, and pass that as a JS setting. If the user's logged in the JS can make an AJAX call to a custom route to grab any necessary data. This could play nicely with Varnish etc. in a way I don't think lazy builders can.

Thanks, hope I'm not time-wasting, this caching stuff can be tough (:

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom AndyF

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

Comments & Activities

Production build 0.71.5 2024