Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Granular Time Cache

Security covered Maintenance fixes only 5 sites

This module provides cache tags that automatically expire at specific time intervals, such as hourly or daily. This is useful for dynamically updating content that has time-based relevance, like an event calendar, without sacrificing performance by making the page uncacheable. It allows for more precise cache invalidation than standard time-based caching.

Granular Time Cache

Provides cache tags that invalidate with time.

Example use case

Think of an event calendar that only shows events whose date is in the future. How to cache that view? You can make the view uncacheable, and and event will disappear the exact second it is finished. But then you have an uncacheable page, very bad for performance. You can set view granularity to daily. Then all "today and future" events are displayed, which is usually fine. Give it a cache max-age and... no that will not work out. What you need is a cache tag that invalidates exactly at midnight.

This module to the rescue. It provides a "granulartimecache:daily" cache tag. Use the file Views Custom Cache Tags module, and you've won.

Available cache tags

The module defines the following granularity cache tags:

  • hourly
  • daily
  • monthly
  • hourly_exact

The last one is for educational purpose: 'hourly_exact' will always last for 60 minutes, while daily will last for 25 h on some days (think DST).

You can implement a hook to add additional tags. If you are convinced that any additional granularity is of popular demand, create an issue, and for best karma points, provide a MR.

Limitations

For the regular calendar-based cache tags, this module supports only one time zone: That set in admin/config/regional/settings (or that of the cron user if timezone by user is set).

For who needs it: Implementing cache tags per timezone should be straightforward though. MR appreciated.

Drupal 8–11

Ask your assistant about Granular Time Cache

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Nov 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.1 Stable 8–11 Nov 23, 2024
1.0.0 Stable 8–11 Nov 22, 2024