Problem/Motivation
The \Drupal\views\Plugin\Block\ViewsBlock::build() function contains the following code
if ($output = $this->view->buildRenderable($this->displayID, [], FALSE)) {
// ...
}
... the FALSE there means that the views output should not be render cached. But it's not clear why we do that; especially since if you look, the block is render-cached.
While trying to track down problems with the block cache, I talked to @dawehner (one of the primary authors of the patch which introduced this call, #2381277: Make Views use render caching and remove Views' own "output caching"), who explained that the real reason why we pass FALSE here is because we don't want to create a dedicated render cache for the view itself. Rather, we want to create a cache for the block only.
Proposed resolution
Since this is not clear, and could be a stumbling block / something that looks like a solution but is not for someone trying to debug render caching, I feel like we should add a short comment to explain why.
Remaining tasks
Write a patch- Review and feedback
- RTBC
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | document_why-2633388-2.patch | 1.12 KB | mparker17 |
Comments
Comment #2
mparker17Here is a patch. Feedback welcome.
Comment #3
dawehnerNice!
Comment #4
jhodgdoncode comments explaining why things are done a certain way +++++ Thanks!
Comment #5
alexpottCommitted 381a888 and pushed to 8.0.x and 8.1.x. Thanks!