Problem/Motivation

Split from #3587806: Add placeholdering to help and branding blocks.

The system does not get placeholdered, so its cache items are looked up one by one instead of via multiple get and set. Originally placeholdering was enabled for the messages block in #3587806: Add placeholdering to help and branding blocks, but that resulted in the messages being added to the bottom of the page when rendered with big pipe. Messages block placeholdering was reverted in that issue to be addressed here separately.

Steps to reproduce

Proposed resolution

Capturing conversation on Slack between @godotislate and @catch about possible root cause and fix:

  • Placeholdering the messages block might mean the wrapper element is not rendered. So the messages JS can't find the wrapper element to inject the messages into as they are added by Big Pipe
  • If so, can maybe get around this by using placeholder strategy deny list and don't allow messages block to be rendered by big pipe
  • Doing so would still reduce the cache get/counts in the performance test by one again

After some investigation the StatusMessages render element already does the placeholdering and lazy building and adds big pipe to the deny list. In which case, the MessageBlock probably can just implement CacheOptionalInterface, so that a render cache item will not be stored for the block. Since status messages are placeholdered already, rendering the block should be cheap, and the cache tags should still bubble to response as expected.

Remaining tasks

Need manual testing to confirm that after the change, status messages still render as expected on the page and not at the bottom. Confirmed, see #6.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#6 messages_block.png45.26 KBdcam

Issue fork drupal-3595648

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

godotislate created an issue. See original summary.

godotislate’s picture

Title: Add placeholdering to messages block » Add do not add render cache entry for messages block
Issue summary: View changes
Status: Active » Needs review
godotislate’s picture

Title: Add do not add render cache entry for messages block » Do not add render cache entry for messages block
godotislate’s picture

Issue summary: View changes
dcam’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new45.26 KB

I tested this by first reproducing the bug that occurred in the other issue. I manually re-added createPlaceholder() to the message block and reinstalled the site from the standard profile. The confirmation message after using drush uli appeared at the bottom of the page.

I reverted that function addition, applied MR 16035, and followed the same test procedure above. The block was not placeholdered and appeared at the top of the page as shown in the following screenshot which is a split-screen image of the rendered page and its HTML.
A split-screen browser with the rendered page on the left displaying the login message at the top of the page and the HTML for the block on the right.

This looks like it's behaving correctly to me.

I went a step further and checked the number of entries in the cache_render table: once on the main branch and once on the MR branch. The CID counts were 11 and 10, respectively. So I did have one less cache entry with this MR, confirming the results of the automated tests.

dcam’s picture

Issue summary: View changes
catch’s picture

Status: Reviewed & tested by the community » Needs review

Had a vague memory we'd tried to do this before and discovered twig template rendering was potentially worse than the cache get, and then found #3516051: Add CacheOptionalInterface to more blocks where @berdir was exploring the same thing and ran some numbers.

I guess the slight difference here is now this is the only block that's not placeholdered we're also saving the cache tag lookup (at least in core, but potentially also on real sites especially if we make placeholdering the default soon). Moving back to needs review for now.