Repository navigation
Version static CSS/JS URLs so updates aren't served from browser cache - #224
Merged
Brandon-Haney merged 2 commits intoOct 6, 2026
Merged
Conversation
Browsers keep /static files across updates, so after an upgrade a new template could run against the previous release's app.js or custom.css. Every CSS/JS include now goes through a static_url() template global that appends a hash of the file's contents, so the URL changes exactly when the file does. Works the same for Docker images, git checkouts and dev builds. A test fails if a template references a CSS/JS file under /static directly.
Several test modules replace web.config in sys.modules with a MagicMock at import time, so a test that imports web.config only gets the real module if it happens to be collected first. static_url() now lives in web/static_assets.py, which has no app imports, and its tests load that module directly. web.config still registers it as a template global.
StudioNirin
approved these changes
Oct 6, 2026
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.
Browsers keep
/staticfiles across updates, so after an upgrade the new HTML can run against the previous release'sapp.jsorcustom.cssuntil the user clears their cache. DeLo1585 ran into this while testing #223 (a new template with an old cachedapp.js), and any release that changes CSS or JS can hit it, including #218 and #219.Change
static_url()template global inweb/config.pythat returns/static/<path>?v=<hash>, where the hash comes from the file's contents. It is cached and recomputed only when the file's modification time changes.base.html, login/link, setup, and the settings pages that loadpath-browser.js/settings_search.js). Images and the favicon are unchanged.GIT_COMMITmeans it works the same on Docker images, git checkouts and dev builds, and a file's URL only changes when that file actually changes.Tests
tests/test_static_url.pycovers the hash, a changed file getting a new URL, an unchanged file keeping its URL, a missing file falling back to the plain URL, and the real static files resolving. It also fails if any template references a CSS/JS file under/staticdirectly, so new includes can't skip it.How to test
?v=followed by a short hash.web/static/css/custom.css(any change), reload the page, and thecustom.csslink has a new?v=value and the change shows without clearing the browser cache.?v=value.