Installer: Add Cache-Control header to static assets
This fixes UX where Launcher iframe blanks when navigating in the app
Change-Id: I2966ef383c77d2986b6892f3828581b7785e90b0
diff --git a/core/installer/welcome/appmanager.go b/core/installer/welcome/appmanager.go
index 0423403..5da26ef 100644
--- a/core/installer/welcome/appmanager.go
+++ b/core/installer/welcome/appmanager.go
@@ -81,9 +81,18 @@
}, nil
}
+type cachingHandler struct {
+ h http.Handler
+}
+
+func (h cachingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Cache-Control", "max-age=604800")
+ h.h.ServeHTTP(w, r)
+}
+
func (s *AppManagerServer) Start() error {
r := mux.NewRouter()
- r.PathPrefix("/static/").Handler(http.FileServer(http.FS(staticAssets)))
+ r.PathPrefix("/static/").Handler(cachingHandler{http.FileServer(http.FS(staticAssets))})
r.HandleFunc("/api/app-repo", s.handleAppRepo)
r.HandleFunc("/api/app/{slug}/install", s.handleAppInstall).Methods(http.MethodPost)
r.HandleFunc("/api/app/{slug}", s.handleApp).Methods(http.MethodGet)