fix: service restart on upgrade and no-cache headers for SPA assets

- postinst: restart instead of start if service already enabled (upgrade case)
- embed.go: no-cache/no-store on index.html, immutable cache on hashed assets
- Fixes web not refreshing after dpkg upgrade
This commit is contained in:
2026-07-07 23:41:16 -04:00
parent 9cef7173cb
commit a79bb29699
3 changed files with 13 additions and 5 deletions
+7 -2
View File
@@ -16,6 +16,7 @@ func ServeHTTP() http.Handler {
}
func ServeSPA() http.Handler {
fsHandler := http.FileServer(http.FS(distSub))
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
path := r.URL.Path
if path == "/favicon.ico" {
@@ -28,11 +29,15 @@ func ServeSPA() http.Handler {
http.Error(w, "not found", http.StatusNotFound)
return
}
w.Header().Set("Content-Type", "text/html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
w.Write(data)
return
}
http.FileServer(http.FS(distSub)).ServeHTTP(w, r)
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
fsHandler.ServeHTTP(w, r)
})
}