From 2c8531d9b9ff52e1fa6ff3eaffdd7239bfa9a808 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Tue, 22 Sep 2026 04:32:22 +0800 Subject: [PATCH] fix: prevent stale web ui caching --- internal/api/root_handler_test.go | 3 +++ internal/api/server.go | 1 + 2 files changed, 4 insertions(+) diff --git a/internal/api/root_handler_test.go b/internal/api/root_handler_test.go index 0fded73..b1c09fe 100644 --- a/internal/api/root_handler_test.go +++ b/internal/api/root_handler_test.go @@ -18,6 +18,9 @@ func TestRootAndAPIDoc(t *testing.T) { if r.Code != 200 || !strings.Contains(r.Body.String(), "My Files") || !strings.Contains(r.Body.String(), "Hello") { t.Fatalf("root: %d %s", r.Code, r.Body.String()) } + if got := r.Header().Get("Cache-Control"); got != "no-store" { + t.Fatalf("root cache-control=%q", got) + } r = httptest.NewRecorder() h.ServeHTTP(r, httptest.NewRequest(http.MethodGet, "/asset/api.html", nil)) if r.Code != 200 || !strings.Contains(r.Body.String(), "/chfs/files") { diff --git a/internal/api/server.go b/internal/api/server.go index 70036bc..7c71fa7 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -1133,6 +1133,7 @@ func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + w.Header().Set("Cache-Control", "no-store") title := s.HTMLTitle if title == "" { title = "CuteHttpFileServer"