From 05874a5bf069c2726f9229efa172787c7125594f Mon Sep 17 00:00:00 2001 From: Quheng Deng Date: Fri, 23 Oct 2026 09:24:48 +0800 Subject: [PATCH] fix(webui): stop browsers serving a stale embedded UI after upgrade (#112) 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. Co-authored-by: WengeLiu101 <233876084+WengeLiu101@users.noreply.github.com> --- internal/admin/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/admin/server.go b/internal/admin/server.go index c963d6a..b333bd1 100644 --- a/internal/admin/server.go +++ b/internal/admin/server.go @@ -97,6 +97,13 @@ func (a *Server) staticHandler() http.Handler { r.URL.Path = "/" } } + // The UI ships inside the binary and only changes when the binary does, + // so a browser that cached app.js/styles.css under a heuristic freshness + // lifetime keeps running the previous build's frontend against the new + // backend — the UI then shows stale pages (or breaks outright) until the + // cache happens to expire or the operator hard-refreshes. Force + // revalidation instead. + w.Header().Set("Cache-Control", "no-cache") files.ServeHTTP(w, r) }) }