Problem/Motivation

In Drupal\sitewide_alert\Controller\SitewideAlertsController::load(), ~ line 104, we see the following code:

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

I'm not sure why we set the cache max age to 30 seconds here. I don't think we should be, especially given the comment above noting that we are just setting making sure alerts are only cached until an alert is created/updated or the module's settings are altered.

I only noticed this because I installed the Cache Control Override module and, for a reason TBD, with that module enabled, the load route always returns a max age of 30. This is interesting behavior. But I noticed that after removing this line setting max age to 30s, the cache max age of the load response is the expected, module configured value, whether I have Cache Control Override installed or not.

Steps to reproduce

Proposed resolution

Don't set the Cache Max Age to 30 here. I do not believe there is a reason to do so.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sonfd created an issue. See original summary.

sonfd’s picture

Status: Active » Needs review

  • smustgrave committed 2f7737f3 on 3.0.x
    Issue #3476702 by sonfd: The Sidewide Alerts load route set a maximum...
smustgrave’s picture

Version: 2.2.1 » 3.0.x-dev
Status: Needs review » Fixed

Agree could not find a reason to keep and didn't break any existing tests or functionality. Think a good candidate for 3.0.x initial release

smustgrave’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.