This module kills Dynamic Page Cache

Created on 14 February 2025, about 2 months ago

Problem/Motivation

In #3258714: Manage attachments cache β†’ , the user cache context was added to markerio_page_attachments(). This means every page now varies by user.

By the time the HtmlRenderer is done calling all page_attachments hooks, we now have a HtmlResponse object that has the user cache context. This means DynamicPageCacheSubscriber will refuse to cache the page, even though the page itself might have been perfectly cacheable otherwise.

Steps to reproduce

Enable this module, see that every page reports "UNCACHEABLE (poor cacheability)" in the "X-Drupal-Dynamic-Cache" header.

Proposed resolution

It seems you're adding some drupal settings in markerio_page_attachments, but can't you use a #lazy_builder somewhere during the render process? Then it will get placeholdered and the page will become cacheable again by DynamicPageCacheSubscriber.

When it gets to HtmlResponseSubscriber, the HtmlResponseAttachmentsProcessor will process the placeholders, adding your attachments to the response. After that, your JavaScript should still get added, but only after DPC has finished doing its thing.

I'm not sure if this widget is intended to be used by anonymous users, but if not then the above should be more than enough to fix the issue.

Remaining tasks

Rethink the caching strategy

User interface changes

/

API changes

/

Data model changes

/

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium kristiaanvandeneynde Antwerp, Belgium

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

Comments & Activities

Production build 0.71.5 2024