Time-based cached views get invalidated too frequently

Created on 2 June 2015, over 9 years ago
Updated 30 October 2023, 11 months ago

Problem/Motivation

Currently time based caching of output works the following:

  • Set an expire/max-age time which is REQUEST_TIME + amount of time configured in the UI
  • It adds cache tags for the output containing the list tag, as well as tags for the view itself

The problem with that is that effectuality, by design, the list tag leads to more invalidations than you actually want.

Proposed resolution

Remove the usage of the list tag for time based caching

Remaining tasks

User interface changes

API changes

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡©πŸ‡ͺGermany dawehner

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States Maeglin

    The current time-based view caching implementation is useful, as long as it's understood what it does, which is setting the max age for query results and rendered output. Unfortunately, the labeling for those config options doesn't make that clear. Cached items might still be invalidated because underlying content has changed, but if you're not setting a minimum age then there's no harm done.

    As for use cases for the way it currently works, I can think of two right away:

    1) The "time ago" date/time field formatter that's built into the core. With only tag-based caching, you might see an update or creation time of "2 hours ago", which could actually be days ago if nothing has changed in that time.

    2) A notification page that I recently built, with dynamic highlighting of messages posted in the last 24 hours. The highlighting is done in the Twig template so, if the rendered output is only refreshed when new notifications are posted, it could be stuck for days.

    In both cases, tag-based invalidation is also desired, so that the views reflect changes to underlying content.

    That's not to say that a min-age setting wouldn't be useful in some cases, but it should be in addition to (not instead of) a max-age setting.

Production build 0.71.5 2024