Compatibility with Purge/Acquia Purge?

Created on 12 October 2023, about 1 year ago

Problem/Motivation

The sitewide alerts module has its own cache_max_age schema/setting that appears to be separate from Drupal core's max-age.

Are there any plans to integrate sitewide alerts cache settings with Drupal core's use of cache tags/contexts so that alerts can be cached at a longer interval and purged by cache tag as needed using Purge/Acquia Purge?

✨ Feature request
Status

Active

Version

2.1

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States btully

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

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

  • Issue created by @btully
  • πŸ‡ΊπŸ‡ΈUnited States btully
  • πŸ‡ΊπŸ‡ΈUnited States chrissnyder Maryland

    There are no current plans. However, this is a good idea. If a MR with this feature is introduced I would be happy to include it in the next release.

  • πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

    It looks like the alerts response is already using the `sitewide_alert_list` cache tag and has the module's settings as a cache dependency.

    See Drupal\sitewide_alert\Controller\SitewideAlertsController:load(), ~line 104 β†’ :

    // Set response cache so it's invalidated whenever alerts get updated, or
    // settings are changed.
    $cacheableMetadata = (new CacheableMetadata())
      ->addCacheContexts(['languages'])
      ->setCacheTags(['sitewide_alert_list']);
    $cacheableMetadata->addCacheableDependency($sitewideAlertSettings);
    
    $response->addCacheableDependency($cacheableMetadata);
    

    In my testing, this is respected and the cache for this route is invalidated as soon as an alert is created/updated/deleted. Which means that I'm able to configure the module's Browser and Shared Cache Maximum Age (in seconds) setting to an extraordinarily high number and still seem updates reflected immediately.

    I wonder if it makes sense to add a new setting to the module's setting form. Something like:

    Use Drupal's Browser and proxy cache maximum age? with a default value of yes
    If no, expose the form as it exists now.

    We'd also need to alter Drupal\sitewide_alert\Controller\SitewideAlertsController::load(), ~line 127 β†’ to respect this new setting.

    And then for BC, we'd need an update hook to set appropriately in existing sites, i.e. to not use Drupal's global max-age.

    Thoughts?

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
Production build 0.71.5 2024