Add a way to specify CACHE_PERMANENT for block caching

Created on 10 May 2009, almost 16 years ago
Updated 28 January 2025, 26 days ago

At both #425728: Add an "issue cockpit" block for project nodes β†’ and #371969: Move developer info into a block provided by cvs.module β†’ I ended up having to do some custom block caching before I could deploy those on d.o. The reason is that the core block caching system always calls cache_set() with CACHE_TEMPORARY. That results in the entire block cache getting cleared on every single cache_clear_all(), e.g. any new comment on the site. It's even worse if you set "minimum cache lifetime" which is also "maximum cache lifetime". :(

Many blocks don't change this often. In a lot of cases, the producer of a given block can be a lot smarter about when to invalidate the cache than this.

Can we add something in the block cache API that lets you not just specify the bit mask for which roles/pages/etc should count for the cache ID, but also a way to specify the cache lifetime? We could probably just do with another bit where 0 == CACHE_TEMPORARY (like we have now) and 1 == CACHE_PERMANENT.

Thoughts?

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

block.module

Created by

πŸ‡ΊπŸ‡ΈUnited States dww

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.

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

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

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

    Wow, blast from the past! Indeed, in D8+ ("modern Drupal"), when you're defining a block (Plugin), you can specify the #cache key and you get all sorts of control.

    https://www.drupal.org/docs/drupal-apis/cache-api/cache-max-age β†’ is still sorta broken. See the Limitations of max-age section β†’ for details. But that's not what this issue was trying to solve.

    Now that D7 is EOL and we're closing all the old issues, this one can die, too.

    Thanks!
    -Derek

Production build 0.71.5 2024