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-tmpl/base.html b/core/installer/welcome/appmanager-tmpl/base.html
index e119c0f..1cd8c3c 100644
--- a/core/installer/welcome/appmanager-tmpl/base.html
+++ b/core/installer/welcome/appmanager-tmpl/base.html
@@ -3,7 +3,7 @@
 	<head>
 		<meta charset="utf-8" />
         <link rel="stylesheet" href="/static/pico.2.0.6.min.css">
-        <link rel="stylesheet" type="text/css" href="/static/appmanager.css">
+        <link rel="stylesheet" type="text/css" href="/static/appmanager.css?v=0.0.1">
 		<meta name="viewport" content="width=device-width, initial-scale=1" />
 	</head>
 	<body>
@@ -26,6 +26,6 @@
 			  {{ block "content" . }}{{ end }}
 		  </div>
       </main>
-    <script src="/static/app-manager.js"></script>
+    <script src="/static/app-manager.js?v=0.0.1"></script>
 	</body>
 </html>
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)
diff --git a/core/installer/welcome/env.go b/core/installer/welcome/env.go
index 15be0eb..5d2206f 100644
--- a/core/installer/welcome/env.go
+++ b/core/installer/welcome/env.go
@@ -125,7 +125,7 @@
 
 func (s *EnvServer) Start() {
 	r := mux.NewRouter()
-	r.PathPrefix("/static/").Handler(http.FileServer(http.FS(staticAssets)))
+	r.PathPrefix("/static/").Handler(cachingHandler{http.FileServer(http.FS(staticAssets))})
 	r.Path("/env/{key}").Methods("GET").HandlerFunc(s.monitorTask)
 	r.Path("/env/{key}").Methods("POST").HandlerFunc(s.publishDNSRecords)
 	r.Path("/").Methods("GET").HandlerFunc(s.createEnvForm)
diff --git a/core/installer/welcome/launcher.go b/core/installer/welcome/launcher.go
index 1d51ee8..288fc60 100644
--- a/core/installer/welcome/launcher.go
+++ b/core/installer/welcome/launcher.go
@@ -134,7 +134,7 @@
 }
 
 func (s *LauncherServer) Start() {
-	http.Handle("/static/", http.FileServer(http.FS(files)))
+	http.Handle("/static/", cachingHandler{http.FileServer(http.FS(files))})
 	http.HandleFunc("/", s.homeHandler)
 	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", s.port), nil))
 }
diff --git a/core/installer/welcome/welcome.go b/core/installer/welcome/welcome.go
index 1592a5c..64f4cf1 100644
--- a/core/installer/welcome/welcome.go
+++ b/core/installer/welcome/welcome.go
@@ -55,7 +55,7 @@
 
 func (s *Server) Start() {
 	r := mux.NewRouter()
-	r.PathPrefix("/static/").Handler(http.FileServer(http.FS(staticAssets)))
+	r.PathPrefix("/static/").Handler(cachingHandler{http.FileServer(http.FS(staticAssets))})
 	r.Path("/").Methods("POST").HandlerFunc(s.createAccount)
 	r.Path("/").Methods("GET").HandlerFunc(s.createAccountForm)
 	http.Handle("/", r)