Problem/Motivation
The version: VERSION lines in libraries.yml are creating a version query string using the Drupal Core version number for the asset files, making these files cached in the browser dependent on the Core version.
Steps to reproduce
This can produce various problems after an update, as the old versions of assets might be loaded for users who have those cached. The only way to currently fix those to clear the browser cache.
Proposed resolution
Remove the version: VERSION lines from libraries.yml. By doing this, Drupal will use an automatically generated query string added to filenames. From the code documentation:
The string changes on every update or full cache flush, forcing browsers to load a new copy of the files as the URL changed.
See: web/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php:62
The other option is to explicitly set the module's version on these lines and keep track of it when the version number changes/the asset is updated.
Issue fork search_api-3495876
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
Comment #3
drunken monkeyThanks a lot for reporting this problem and already proposing a fix!
It indeed seems like we misunderstood the purpose of the
versionkey when initially creating thesearch_api.libraries.ymlfile. Your explanation makes sense and the code inJsCollectionRenderer::render()seems to corroborate it as well. Still, as I have very little expertise in this area of Drupal development I’ll leave this issue open another week or so to give others a chance to weigh in before merging.Comment #4
dieterholvoet commentedIf it can be a reassurance: a lot of other major contrib modules have the same issue and have already committed the fix. I linked a couple of them.
Comment #6
drunken monkeyThanks, very helpful! Then yes, it seems clear that this is the right thing to do.
Merged.
Thanks a lot again!