Drupal is a registered trademark of Dries Buytaert
Search API Solr 4.4.0 Minor update available for module search_api_solr (4.4.0). Page Manager 8.x-4.0 Major update available for module page_manager (8.x-4.0). Trash 3.1.0-beta2 New beta version released for module trash (3.1.0-beta2). Commerce AutoSKU 3.0.1 Minor update available for module commerce_autosku (3.0.1). Custom Field 4.0.10 Minor update available for module custom_field (4.0.10). Alternative login ID & display names 2.0.12 Minor update available for module alt_login (2.0.12). EntityReference UUID 3.0.1 Minor update available for module entity_reference_uuid (3.0.1). LocalGov Publications Importer 1.1.1 Minor update available for module localgov_publications_importer (1.1.1). Configuration Override Warn 8.x-1.6 Module config_override_warn updated after 10 months of inactivity (8.x-1.6). Table Alternate Rows Module table_altrow crossed 1,000 active installs.

This module automatically sets an appropriate cache lifetime for views that are filtered by date, ensuring that results reflecting the current time remain fresh without manual guesswork. It intelligently calculates the exact moment a view's results will next change and purges the cache at that specific time, preventing stale content from being displayed. This is particularly useful for views like archives, upcoming events, or currently running items.

Inspired by https://www.drupal.org/project/drupal/issues/2968485, this module allows you to set a sensible result cache lifetime on Views that are filtered by a date, so they stay fresh without you having to guess a max-age.

If a view shows content based on the current time (today's news, upcoming events, things happening right now) the results will change at some point in the future. Core's time based caching makes you pick a fixed lifetime: set it too long and the view serves stale results, too short and you throw the cache away for nothing. This module works out the exact moment the result set next changes and expires the cache then.

IMPORTANT: If you want the max age to bubble through to the response so it works against varnish, CDN and browser caches, you will also need https://www.drupal.org/project/cache_control_override

How it works

Choose Date filter as the caching strategy on a view, then tick the date filter (or filters) that bound the results. The cache is held until the next item is due to enter or leave the view, going by those filters.

It works this out by asking the database for the single nearest item on the other side of each filter, so the lifetime is exact rather than estimated. The results only need rebuilding when that moment arrives, or when the content itself changes, which cache tags already handle.

What it caches well

🗄️ Archive views

A "less than" filter such as event date < now. The result grows over time as content passes the filter, so the cache lasts until the next item is due to appear.

📅 Upcoming views

A "greater than" filter such as event date > now. The result shrinks over time as items pass, so the cache lasts until the soonest item is due to drop out.

⏱️ Currently running views

Two filters together, such as start <= now and end >= now on a date range field. Tick both and the cache lasts until whichever happens first: the next item to begin, or the next to end.

Supported fields and filters

  • Date and datetime fields, including the created and changed node columns.
  • Date range fields, including all day ranges. Filter on the start or the end column, whichever bounds your view.
  • Filters reached through a relationship.
  • The simple operators <, <=, > and >=.

Things to know

  • Exposed filters are not handled. Their value changes per visitor, so there is no single point to cache against. Use core's Tag based caching for those views.
  • The lifetime is conservative. It never serves stale content, though on a view with other filters it may sometimes rebuild a little earlier than strictly needed.
  • If the lifetime cannot be worked out, caching is turned off for that view rather than risk serving stale results.


Activity

Total releases
3
First release
Jun 2026
Latest release
1 month ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.0-beta3 Pre-release Jun 17, 2026
1.0.0-beta2 Pre-release Jun 16, 2026
1.0.0-beta1 Pre-release Jun 12, 2026