Bring back the asset stale file threshold

Created on 11 February 2025, about 1 month ago

Problem/Motivation

In 📌 Remove the aggregate stale file threshold and state entry Fixed we removed the aggregate stale file threshold - it used to be the only way to safely garbage collect old asset files, because if files were removed immediately after a cache clear, then requests for cached HTML would find missing aggregates.

With AssetControllerBase and the logic around that, we now have a fallback when a file is missing - if the request is valid, or nearly valid, Drupal will serve a response.

However, generating aggregate assets is still quite expensive when a file doesn't exist, and it's quite possible that caches are cleared and deployments happen when various libraries haven't been updated.

Since 🐛 Ensure that edge caches are busted on deployments for css/js aggregates Fixed , aggregate filenames are based on either the library version if there is one, or the contents of the asset files themselves if the library does not have a version. This takes care of cache busting pretty well (as long as sites do one or the other and don't change library assets without also changing the version).

Given all the above, it think we should consider re-introducing the stale file threshold concept, and only delete asset aggregates that are over 30 days old by default. This will ensure that old files eventually get garbage collected, but will also mean they have to be regenerated less.

We can make this behaviour dependent on the dev mode toggle, so that local development still deletes all the files. Add a Production/Development Toggle To Core Needs work .

Steps to reproduce

Proposed resolution

Add $settings['aggregate_gc_threshold'] defaulting to 30 days.

Copy back the logic that was removed from 📌 Remove the aggregate stale file threshold and state entry Fixed (more or less, it'll need updating slightly) to delete only files older than the threshold.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

asset library system

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024