Problem/Motivation
#3587806: Add placeholdering to help, messages, branding blocks shows that placeholdering blocks, even very simple ones, has a small but wide-ranging improvement on performance, by allowing render cache items and cache tags to be retrieved together instead of one by one.
Where blocks are rendering entities or generating links etc., they also get the advantage of fiber-based entity and path alias pre/lazy loading.
We could set ::createPlaceholder() to TRUE so that this happens by default for contrib and custom blocks too.
The only downside is it will mean more sites will run into #3533588: Add a mechanism to filter out empty theme regions when all blocks inside are empty but this might be something we could do in 12.x only with a change record and release note.
Comments
Comment #2
alexpottComment #3
berdirAre there blocks that should not use placeholdering and if so, why?
What about blocks that uncacheable/have max-age 0 for example? Like LanguageBlock used to before we added CacheOptionalInterface. We've used that extensively on ad placeholder blocks in the past as they were very inexpensive to build but varied on every page, so it was kind of useful to have them cached by dynamic page cache.
I also did some testing on using CacheOptionalInterface in more blocks but essentially found out that caching is useful even for tiny and static blocks as the block template adds enough overhead that caching is useful, especially when we can do it in bulk. One of the few exceptions is blocks that are pretty fast *and* vary on every page like language switcher and that ad example. See #3516051: Add CacheOptionalInterface to more blocks
Comment #4
catchI can't really think of examples except for LanguageSwitcher, which to me makes me think we should do this, and the very special cases should opt out.
max-age 0 already gets placeholdered due to auto-placeholdering - that predates the createPlaceholder() issue.