css_js_agg_retention
This module restores time-based garbage collection for CSS and JavaScript aggregates, preventing the complete deletion of aggregate directories during cache rebuilds that was introduced in 10.1.
Background
Drupal 10.1 introduced significant performance improvements to CSS/JS aggregation by implementing lazy generation of aggregate files. However, these changes also modified cache clearing behavior to delete entire /sites/*/files/{css,js} directories during every cache rebuild (drush cr).
While this approach works well for dynamic sites where aggregates can be regenerated on-demand, it creates critical issues for static generators.
This module reinstates the pre-10.1 behavior by preventing wholesale deletion of CSS/JS directories during cache clears and implementing time-based cleanup that only removes genuinely stale files.
Relates issues:
- #3301573: Remove the aggregate stale file threshold and state entry