Repository navigation
Templates: Version asset links so updates bypass the browser cache - #64
Merged
Merged
Conversation
Forgejo serves custom assets with a six-hour max-age and the templates linked them by a fixed path, so after a theme update browsers kept running the previous build's scripts against the new markup. The source tree then failed with "Could not load the file tree" because the cached script still requested the removed data-api-url. The assemble step now appends each linked stylesheet and script's content hash as a version query, and fails when a template links an asset the build does not ship. That check surfaced three stale stylesheet links in the navbar, which duplicated component_assets and are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
After a theme update, browsers keep running the previous build's scripts against the new templates. Forgejo serves custom assets with
Cache-Control: private, max-age=21600, and the templates link them by a fixed path, so nothing tells the browser the file changed.This showed up as "Could not load the file tree. Reload to try again." on file pages after moving from 0.2.0 to
dev. The cached 0.2.0repo-source-browser.jsstill readdata-api-url, which #60 removed fromsource_tree.tmpl, so it requested…/src/branch/dev/undefined&page=1and got a 404. A hard reload clears it; otherwise it lasts up to six hours per visitor.Changes
?v=query indist/forgejo/templates. A link only changes when its file does. Source templates are unchanged.base/head_navbar.tmpl(css/user-profile.css,css/profile-subpages.css,css/organization.css), which 404 on profile and organization pages.base/component_assets.tmplalready loads the same files fromcss/components/pages/, so they are removed.Not covered
The
theme-github-*.cssfiles are linked by Forgejo's own head template with Forgejo's version as the query, so they can still be served stale for up to six hours after a theme update.Checks
bun commitpasses (383 tests), including a new test that every template asset link carries the hash of the shipped file. No visual change, so there are no before/after screenshots.ref #60
🤖 Generated with Claude Code