Repository navigation
Add content hashes to UI stylesheet and script URLs - #215
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The site loads its stylesheets and scripts from fixed URLs such as
_/css/site.css. The IntelliJ IDEA built-in browser keeps the copies it cached, so after a release it shows new pages with old styles until the user runs Invalidate Caches.Now each UI stylesheet and script URL carries a hash of the file content, for example
_/css/site.css?v=2eca4c9a57. A changed file gets a new URL, and the browser loads it.ui/asset-hash-extension.jsis an Antora extension. It hashes every CSS and JS file of the UI (ours, the bundle's and the Lunr extension's) and registers theassetHandlebars helper.head-styles.hbsandfooter-scripts.hbsreference the files as{{{asset 'css/site.css'}}}instead of{{{uiRootPath}}}/css/site.css. The helper fails the build when the UI has no such file.Missing helper: "asset", so a production playbook kept outside this repository needs the same line.ui/README.mdandAGENTS.mddescribe the helper.search-index.jsis not a UI file and stays without a hash. The hashes work only when the browser requests fresh HTML, so the server should send the pages withCache-Control: no-cache.Checked: the site builds, all 13 hashes in the HTML match the published files, and
node tools/ui-audit.mjspasses.