Once #1605290: Enable entity render caching with cache tag support lands we'll have cache tags applied for all entities on a page.
This leaves two places that do render caching that don't support them yet:
#1712456: How to leverage cache tags in Views for Views.
And this issue for the page cache. I couldn't find an issue for this, but there might be an old one somewhere.
So for the page cache, we need to collect all the cache tags added throughout the request and store them when we save it, all the invalidation will be handled by the existing validation.
Comment | File | Size | Author |
---|---|---|---|
#19 | drupal8.base-system.2094241-19.patch | 6.19 KB | moshe weitzman |
#19 | interdiff.diff | 1.72 KB | moshe weitzman |
#16 | page-cache.diff | 6.53 KB | moshe weitzman |
#15 | page-cache.diff | 6.53 KB | moshe weitzman |
#13 | drupal8.base-system.2094241-13.patch | 6.55 KB | moshe weitzman |
Comments
Comment #1
catchComment #2
Wim LeersYes yes yes yes yes +1000.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedThis turned out to be pretty straightforward. We only have access to the processed page array during drupal_render_page() so we have to calculate and stash away our list of tags at that time. I chose to add a #post_render callback at the top level of the $page array and do collection and storage of tags there. We then fetch those collected tags later during drupal_page_set_cache().
We were not correctly tagging nodes with their author's uid so I fixed that line in this patch. It was giving an error.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedBetter code comments.
Comment #6
Wim Leers#4: drupal8.base-system.2094241-4.patch queued for re-testing.
Comment #7
Wim LeersFixing nitpicks.
Comment #8
amateescu CreditAttribution: amateescu commentedShouldn't we default to an array here instead of false? Just like in drupal_cache_tags_page_get().
Since $entity is actually a class that implements NodeInterface, we should use $entity->getAuthorId().
Comment #9
amateescu CreditAttribution: amateescu commentedMy review points are trivial, I think this is ready to go.
Comment #10
Wim LeersSorry, to un-RTBC, but this still needs tests.
Comment #11
amateescu CreditAttribution: amateescu commentedMy view on testing was that we don't need them at the moment because there's nothing to break here, we either get some cache tags from a render array or we don't.
Now, if we want to go further and remove the 'content' cache tag, that will definitely need testing.
Comment #12
catchIt would be lovely to remove the 'content' cache tag, not sure if that should happen in this issue. And we'd need to ensure that cache tags for all entities rendered get correctly added to the page cache and that it gets cleared by two or more in a functional test I think, but yeah that somewhat depends on removing the content tag if it'll be at all realistic.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedThanks for the feedback and rerolls. Here is a new patch with a test.
Comment #15
moshe weitzman CreditAttribution: moshe weitzman commentedReroll
Comment #16
moshe weitzman CreditAttribution: moshe weitzman commentedActually this one
Comment #17
moshe weitzman CreditAttribution: moshe weitzman commentedWe are green now, with a proper web test. Anyone care to review and RTBC?
Comment #18
amateescu CreditAttribution: amateescu commentedReally minor point :) "Tests that cache tags ..."
This procedural wrapper is marked as deprecated, we should use
Cache::invalidateTags()
directly instead.This new tag doesn't seem to be used or invalidated anywhere, shouldn't we remove it?
Comment #19
moshe weitzman CreditAttribution: moshe weitzman commentedGood catches. Fixed all those.
Comment #21
amateescu CreditAttribution: amateescu commentedLooks good now :)
Comment #22
Wim LeersYep, looks good :)
Comment #23
catchCommitted/pushed to 8.x, thanks!
I opened #2124957: Replace 'content' cache tag with 'rendered' and use it sparingly for content cache tag removal.