Repository navigation
fix(webui): stop browsers serving a stale embedded UI after the binary is upgraded - #112
Merged
jasonxu114514 merged 1 commit intoOct 23, 2026
Conversation
The management UI is embedded in the binary (//go:embed) and served through http.FileServerFS. Those responses carry no Cache-Control, and the embed FS reports a zero modification time, so there is no Last-Modified or ETag either. Browsers are therefore free to apply heuristic caching and keep an old index.html/app.js/styles.css for hours. That is invisible until the operator upgrades the binary: the new backend then serves requests that the cached old frontend does not know about, so newly added pages never appear (or the UI breaks) until the cache expires or the user hard-refreshes. Set Cache-Control: no-cache on the embedded assets so the browser always revalidates. Revalidation is cheap against a local server, and it makes the UI version follow the binary version, which is the invariant the embed implies.
WengeLiu101
pushed a commit
to WengeLiu101/opencode2api
that referenced
this pull request
Oct 24, 2026
TiaraBasori
added a commit
to TiaraBasori/opencode2api-1
that referenced
this pull request
Oct 25, 2026
…breaker) Pick up origin/main (19 commits since v1.4.3): - 2.1.1 client shape: version bump, /inference/openai|anthropic family routes, max_completion_tokens 32000, strict:false tools, client key order, no HTML escaping, runtime-owned Accept/Content-Length (jasonxu114514#141-jasonxu114514#143) - anonymous-lane abuse handling: IP-block detection, per-exit block TTL, circuit breaker (models.anonymous_backoff), max_anonymous_exits cap, deterministic 4xx stops the walk instead of replaying every exit - placeholder key dropping, probe failure classification (jasonxu114514#111), WebUI Cache-Control (jasonxu114514#112), reasoning disable preserved end to end (jasonxu114514#150), Italian README/WebUI Conflict resolutions: - internal/config/config.go, README.md, README.zh-CN.md: kept both sides — the alias fields (aliases/strip_free_suffix) and the new anonymous_backoff block sit side by side in ModelsConfig and the README tables. Local adaptation for this deployment's #pool exit (not upstream): - a #pool transport dials a fresh upstream address on every attempt, so an IP-scoped abuse block cannot be parked on the transport: blocked() and markBlocked() ignore pool transports and the anonymous walk keeps rotating instead of freezing every exit behind one flagged address.
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.
Problem
The management UI is embedded in the binary (
//go:embed) and served throughhttp.FileServerFS.Those responses carry no
Cache-Control, and the embed FS reports a zero modification time, so there isno
Last-Modifiedand noETageither. With nothing to go on, browsers are free to apply heuristic caching andkeep an old
index.html/js/*.js/css/*.cssfor hours.That stays invisible until the operator upgrades the binary. Then the new backend serves requests the cached old
frontend does not know about — newly added pages simply never appear, and a renamed asset or changed API shape
breaks the page outright — until the cache happens to expire or the user hard-refreshes.
Concretely: after adding a new page to the WebUI and restarting the binary, the nav entry and page were missing
in the browser while
curlagainst the same server returned them, and onlyCtrl+Shift+Rfixed it.Fix
if r.URL.Path != "/" && r.URL.Path != "/index.html" { if _, err := fs.Stat(assets, strings.TrimPrefix(r.URL.Path, "/")); err != nil { r.URL.Path = "/" } } + w.Header().Set("Cache-Control", "no-cache") files.ServeHTTP(w, r)no-cachemeans "revalidate before reuse", not "don't store" — the browser keeps the asset but must check withthe server first. Against a local management server that check is free, and it makes the UI version follow the
binary version, which is the invariant
//go:embedalready implies.Verification
|
curl -I http://127.0.0.1:8791/→Cache-Control: no-cache(was: header absent).Notes / alternatives
A content-based
ETag(e.g. keyed on the build version) would additionally make revalidation answer304insteadof re-sending the asset. That is more code and needs care for
devbuilds;no-cachealone already fixes thestaleness, so this PR keeps the change to one line. Happy to follow up with the ETag version if preferred.