Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The code used to generate the cid is:
$cid = 'css:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($assets)) . (int) $optimize;
This means anything in $assets is part of the cache ID. As this includes drupalSettings this can include all sorts of things. Core's AssetResolver does:
// Add the theme name to the cache key since themes may implement
// hook_library_info_alter().
$libraries_to_load = $this->getLibrariesToLoad($assets);
$cid = 'css:' . $theme_info->getName() . ':' . Crypt::hashBase64(serialize($libraries_to_load)) . (int) $optimize;
Proposed resolution
Make it cache by library not the entire asset array.
Remaining tasks
Tests?
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#3 | 2782591.4.patch | 2.91 KB | alexpott |
Comments
Comment #2
alexpottSee #2603138: CSS/JS asset caching can easily be trashed for more info
Comment #3
alexpottHere's a patch the brings core's logic into the advagg version.
Comment #4
NickDickinsonWildeThanks for the patches :D
Again, I'll commit now without test for time sake (woohoo more debt).
Comment #6
NickDickinsonWilde