Repository navigation
Templates: Version the theme stylesheet so updates bypass the browser cache - #71
Merged
Merged
Conversation
… cache Template scripts and component stylesheets are already linked by content version, but the theme's main stylesheet was not. Forgejo links it with its own release as the only version and lets browsers cache it for six hours, so after a theme update the new markup rendered with the previous stylesheet until the cache expired or the page was reloaded without it. The theme now overrides Forgejo's two-line head_style partial. It is identical except that the build appends a version of all theme files to the theme link. The auto themes import their light and dark files by a fixed path, so each of those imports gets the version of the file it loads. 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, pages rendered with the new templates but the previous theme stylesheet until the browser cache expired. #64 versioned the scripts and component stylesheets the templates link; this closes the gap it left for the main
theme-*.cssfiles.Cause
Forgejo links the selected theme as
theme-<name>.css?v=<Forgejo version>and serves it withCache-Control: max-age=21600. A theme update does not change Forgejo's version, so the URL stays the same and browsers keep the cached file for up to six hours. The auto themes add a second layer: they@importtheir light and dark files by a fixed path.Seen after deploying #70: the pull request list showed its new heading row and counters with the old layout rules (button beside the heading, icons on Open/Closed, old filter order).
Changes
base/head_style.tmpl: the theme overrides Forgejo's two-line partial. It is identical except that the build appends a version of all theme files to the theme link:?v={{AssetVersion}}-<theme version>. Forgejo's ownindex.csslink is unchanged.@importintheme-*-auto.cssgets the content version of the file it loads. This is done indist, so the release archives carry it too.index.csslink is left alone.Limits
Checks
bun commitchecks pass (403 tests), including a new test that the theme link and every auto-theme import carry the version of the files they load. Running the assemble step twice gives the same output.theme-github-auto.css?v=16.0.3~gitea-1.22.0-<version>, the stylesheet and its versioned imports load, no template errors are logged, and the pull request list renders as before.ref #64
🤖 Generated with Claude Code