Views' cache with relative date filter is not invalidated when needed

Created on 1 May 2018, over 6 years ago
Updated 13 May 2023, over 1 year ago

The use case seem pretty common for example on event website. You want your old event not to appear on the "current event" listing when their date is in the past.

You will configure a filter like that:

The problem is that anonymous user still see the old events because the caches are note invalidate.

A workaround is to clear custom tag-cache on cron run https://bkosborne.com/blog/keeping-view-upcoming-events-fresh-drupal-8

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated 30 minutes ago

Created by

πŸ‡¨πŸ‡­Switzerland gagarine

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡¦πŸ‡ΊAustralia darvanen Sydney, Australia

    I thought this was a good idea from #10:

    We could use the offset set in each date filter and calculate the timestamps for each row when it wouldn't be included in the results anymore.
    We can the use the minimum timestamp we get per row as the max-age

    However, according to the helpful folks on Drupal Slack... views cache metadata isn't compiled at runtime but saved in config, so unless that changes this approach won't work.

    I don't think disabling cache entirely is the answer though.

  • πŸ‡¦πŸ‡ΊAustralia darvanen Sydney, Australia

    Here's a start on a contrib module: https://www.drupal.org/project/vcp4dates β†’

    Feedback very welcome.

Production build 0.71.5 2024