Provide cache buster query string on imports

Created on 15 July 2025, 4 days ago

Overview

When upgrading XB between alpha releases, pages can appear broken. A hard refresh is required by browsers to bypass browser cache for the bundled assets and imports.

Proposed resolution

Load bundle.js and friends with a cache buster query string

User interface changes

๐Ÿ› Bug report
Status

Active

Version

0.0

Component

โ€ฆย to be triaged

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

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

Merge Requests

Comments & Activities

  • Issue created by @mglaman
  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland lauriii Finland
  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    So we have the items in the import map generated in \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\JsComponent::renderComponent.

    Then we have a lot of JS files included in libraries (i.e. in experience_builder.libraries.yml) where the version gets appended from the library definition, but we never update those, and it's not even feasible for xb-ui as that gets recompiled and updated constantly. How are those usually handled? I think I've seen it before that a hash was added to the filename by the JS bundler, and the filename was read in hook_library_info_alter().

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    (trying to categorize this, not sure what is the best match, assuming Page builder)

    If I understood this, most of the issues come from js components?
    Adding a cache buster query there from AssetQueryStringInterface.
    Wondering if we could use the component version though.

    Then we have a lot of JS files included in libraries (i.e. in experience_builder.libraries.yml) where the version gets appended from the library definition, but we never update those, and it's not even feasible for xb-ui as that gets recompiled and updated constantly. How are those usually handled? I think I've seen it before that a hash was added to the filename by the JS bundler, and the filename was read in hook_library_info_alter().

    I see 2 options here:

    1) KISS, just remove version, and Drupal will handle it using the same AssetQueryStringInterface that uses for the rest of assets.
    2) hook_library_info_alter reading ui/package.json, which we should keep in sync on release numbers.

  • Pipeline finished with Failed
    4 days ago
    Total: 865s
    #548275
  • Pipeline finished with Failed
    4 days ago
    Total: 494s
    #548312
  • Pipeline finished with Failed
    4 days ago
    Total: 782s
    #548317
  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    Needs feedback on direction.

  • Pipeline finished with Failed
    4 days ago
    Total: 661s
    #548325
  • Pipeline finished with Failed
    4 days ago
    Total: 837s
    #548346
  • Pipeline finished with Failed
    4 days ago
    Total: 1698s
    #548366
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    +1 for keeping it simple in the first instance

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    FWIW we could also configure vite to include hash in filenames https://rollupjs.org/configuration-options/#output-entryfilenames
    That's something we do on client projects

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    We now use the package.json version (or a hashed variation of that).
    Back to Lee for review in case he has the time, I will pass this by Bรกlint tomorrow morning.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    (trying to categorize this, not sure what is the best match, assuming Page builder)

    Appreciate that! ๐Ÿ˜Š

    But it should be , since this is a problem only for the js ComponentSource plugin ("code components").

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    Ended up implementing a MockVersion for testing purposes. All feedback addressed.
    Crediting effulgentsia for feedback on MR.

  • Pipeline finished with Success
    3 days ago
    #548978
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    This looks really great!

    I think long term we should consider what both @larowlan and I suggested (in #9 and #4), having Vite/Rollup output filenames with a hash in them. That would allow us to do releases with backend-only changes where we don't force re-downloading unchanged JavaScript assets.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    Oops, didn't mean to do that.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #17++ โ€” but we'll still need what this MR does for the xb-ui asset library's definition itself. Tagging for this ๐Ÿ‘

    So very close!

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Reflecting the slightly expanded scope per @balintbrews and my request ๐Ÿ˜‡

  • Pipeline finished with Canceled
    3 days ago
    Total: 554s
    #549123
  • Pipeline finished with Canceled
    3 days ago
    Total: 121s
    #549128
  • Pipeline finished with Failed
    3 days ago
    Total: 639s
    #549130
  • Pipeline finished with Canceled
    3 days ago
    Total: 190s
    #549179
  • Pipeline finished with Failed
    3 days ago
    Total: 613s
    #549182
  • ๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

    Now we fallback to AssetQueryString also in xb-ui and astro libs.

    #17, #19: That might make harder to include the assets as we do right now, and specially would make tests more complicated? Not sure how worth would it be, and it would differ from what core does.

  • Pipeline finished with Success
    3 days ago
    Total: 838s
    #549190
  • Pipeline finished with Success
    3 days ago
    Total: 812s
    #549224
  • Pipeline finished with Success
    3 days ago
    Total: 1039s
    #549931
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    LGTM โ€” and many thanks for the โ„น๏ธ comments on the MR, @penyaskito!

    Just added some clarifying comments based on the discussion on the issue + MR and fixed some language nits โ€” ๐Ÿšข

  • Pipeline finished with Failed
    3 days ago
    Total: 742s
    #549949
  • Pipeline finished with Success
    3 days ago
    Total: 821s
    #549973
  • Pipeline finished with Skipped
    3 days ago
    #549986
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    ๐Ÿฅณ

    Still needs follow-up issue for #4 + #9 + #17, which are all about the same thing.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Thanks, @mayur-sose!

Production build 0.71.5 2024