Add the deployment_identifier to CSS and JavaScript aggregate hashes

Created on 2 July 2023, about 1 year ago
Updated 3 July 2023, about 1 year ago

Problem/Motivation

Spun-off from 🐛 Ensure that edge caches are busted on deployments for css/js aggregates Fixed .

Library aggregate hashes are based on the library definition (i.e. the YAML) not the file contents, this makes the hashes cheaper to calculate. However if the file contents change without the library definition changing, then the file itself won't change.

Core libraries tend to use VERSION for the library version, this means that many aggregates will be invalidated when a site updates to a new patch release.

Custom libraries (i.e. from custom themes and modules) often don't set any version at all.

Steps to reproduce

Proposed resolution

Add the deployment_identifier to aggregate hashes.
For sites that don't set a deployment identifier, this will be set to Drupal::VERSION - so aggregates that already include \Drupal::VERSION will be unaffected.

For aggregates that don't include it (i.e. only including custom libraries, or only including properly-versioned libraries like jQuery etc.), they'll get invalidated more often.

This brings up an issue though - if a site fully-embraces the new aggregation algorithm, they could set an explicit version on every library, and that will maximise the cache lifetime of each aggregate. If we always set deployment_identifier on hashes, then that strategy won't work the same.

So there are maybe four ways to do this:

1. Always add deployment_identifer to aggregate hashes.
2. Add an extra setting (defaulting to TRUE), and when this is set, add deployment_identifier to hashes, allowing sites to disable it.
3. Instead of adding the deployment_identifer to hashes directly, backfill version in library definitions when it's not set, and then hash based on that. This would mean that any aggregate where all the libraries are versioned would be unaffected. We can do this when building the hash only, so it's transparent to other code too.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Closed: duplicate

Version

11.0 🔥

Component
Asset library 

Last updated 1 day ago

No maintainer
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