fix: prevent stale web ui caching
This commit is contained in:
@@ -18,6 +18,9 @@ func TestRootAndAPIDoc(t *testing.T) {
|
|||||||
if r.Code != 200 || !strings.Contains(r.Body.String(), "<title>My Files</title>") || !strings.Contains(r.Body.String(), "<strong>Hello</strong>") {
|
if r.Code != 200 || !strings.Contains(r.Body.String(), "<title>My Files</title>") || !strings.Contains(r.Body.String(), "<strong>Hello</strong>") {
|
||||||
t.Fatalf("root: %d %s", r.Code, r.Body.String())
|
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()
|
r = httptest.NewRecorder()
|
||||||
h.ServeHTTP(r, httptest.NewRequest(http.MethodGet, "/asset/api.html", nil))
|
h.ServeHTTP(r, httptest.NewRequest(http.MethodGet, "/asset/api.html", nil))
|
||||||
if r.Code != 200 || !strings.Contains(r.Body.String(), "/chfs/files") {
|
if r.Code != 200 || !strings.Contains(r.Body.String(), "/chfs/files") {
|
||||||
|
|||||||
@@ -1133,6 +1133,7 @@ func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
w.Header().Set("Cache-Control", "no-store")
|
||||||
title := s.HTMLTitle
|
title := s.HTMLTitle
|
||||||
if title == "" {
|
if title == "" {
|
||||||
title = "CuteHttpFileServer"
|
title = "CuteHttpFileServer"
|
||||||
|
|||||||
Reference in New Issue
Block a user