Problem/Motivation

The node_list cache tag is very generic. We've already introduce a list cache tag per bundle #2145751: Introduce ENTITY_TYPE_list:BUNDLE cache tag and add it to single bundle listing and are looking at how to use it - #3055371: Use new cache tag ENTITY_TYPE_list:BUNDLE in Views to improve cache hit rate. But there is another issue. Every time an unpublished node is edited or a draft created the list cache tags are invalidated. This means that an editor doing small edits to an article whilst preparing an article is behaving like a cache buster for any views that list nodes - for example taxonomy listing, recent content and the frontpage view. Since the node is unpublished none of these changes will cause any real changes.

Steps to reproduce

Proposed resolution

Introduce an published list cache tag and work together with #3055371: Use new cache tag ENTITY_TYPE_list:BUNDLE in Views to improve cache hit rate to work out how views filters can alter the list cache tags of a view.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

alexpott created an issue. See original summary.

alexpott’s picture

alexpott’s picture

Title: Add and use a node_list:published cache tab » Add and use a node_list:published cache tag
geek-merlin’s picture

Great question at a great time.

I stated another instance of this in comments #3055371-24: Use new cache tag ENTITY_TYPE_list:BUNDLE in Views to improve cache hit rate, #3055371-38: Use new cache tag ENTITY_TYPE_list:BUNDLE in Views to improve cache hit rate, #3055371-43: Use new cache tag ENTITY_TYPE_list:BUNDLE in Views to improve cache hit rate, but guess it was not groked in the debate.

How i understand the context of this:

We want cache tags with a granularity finer than the list tag, for pre-filtered views lists (such that creating or updating an entity outside that list will not invalidate the view).

We now HAVE the ENTITY_TYPE_list:BUNDLE cache tags, and there are good reasons to add ENTITY_TYPE_list:published cache tag.

Note that this clashes if a bundle is named "published".

So we arrive at the question: which of the potentially infinite list of filtered views do we support in core?
- Maybe we leave all to contrib.
- Maybe we find a way to name cache tags after their JsonApi query string and let sitebuilders configure which are handled.
(So in this case something like ENTITY_TYPE_list:_jsonapi:published=1

So this new use case raises the question: How do we allocate the cache tags namespace?
(But from your comment in the other issue it's clear to me that i'm not smarter than you, and you had that question in mind ;-).

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

les lim’s picture

How would this work, in theory? Say I make a minor edit to an unpublished node, leaving it unpublished. Which cache tags would we then invalidate?

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

Rather than adding new subdivisions of list caching one by one, I wonder whether we could add something generic: see #3279764: Segmented ENTITY_TYPE_list:* cache tags.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.