fix(cache): replace 1-year immutable cache with no-cache revalidation across all static and console routes

This commit is contained in:
2026-11-07 12:19:18 +05:30
parent 76783b95e6
commit 777863a635
3 changed files with 24 additions and 3 deletions
+9 -1
View File
@@ -674,6 +674,9 @@ func sendPasswordResetEmail(toEmail, token, service string) {
// handleForgotPassword handles GET (show form) and POST (send reset email).
func handleForgotPassword(w http.ResponseWriter, r *http.Request, service string) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
if r.Method == "GET" {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
data := map[string]any{"Service": service, "Step": "request"}
@@ -887,12 +890,17 @@ func main() {
mux.HandleFunc("/tailwind.css", func(w http.ResponseWriter, r *http.Request) {
data, _ := templatesFS.ReadFile("templates/tailwind.css")
w.Header().Set("Content-Type", "text/css; charset=utf-8")
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
w.Write(data)
})
mux.HandleFunc("/three.min.js", func(w http.ResponseWriter, r *http.Request) {
data, _ := templatesFS.ReadFile("templates/three.min.js")
w.Header().Set("Content-Type", "application/javascript; charset=utf-8")
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
w.Write(data)
})
RegisterS3ConsoleRoutes(mux)
+4
View File
@@ -171,6 +171,10 @@ func handleS3ConsolePage(w http.ResponseWriter, r *http.Request) {
})
var username string
scyllaSession.Query(`SELECT username FROM cosmos.users WHERE session_id=? ALLOW FILTERING`, sid).Scan(&username)
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
tmpl.ExecuteTemplate(w, "oortconsole.html", map[string]string{"SID": sid, "Username": username})
}
+11 -2
View File
@@ -545,6 +545,9 @@ func handleOrbitConsole(w http.ResponseWriter, r *http.Request) {
return
}
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
data := map[string]interface{}{
"UserEmail": email,
@@ -1088,7 +1091,10 @@ func handleOrbitProxy(w http.ResponseWriter, r *http.Request, path string) {
}
if status != "running" {
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.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, `<!DOCTYPE html><html><body style="background:#090d16;color:#e2eaf2;font-family:sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;"><div style="text-align:center;"><h2 style="font-size:24px;">Application is %s</h2><p style="color:#64748b;">Please start the container from the Orbit console to access it.</p><a href="/orbit" style="display:inline-block;margin-top:16px;color:#38bdf8;text-decoration:none;padding:8px 16px;border:1px solid rgba(56,189,248,0.3);border-radius:8px;">Open Orbit Console</a></div></body></html>`, status)
return
}
@@ -1318,7 +1324,10 @@ func handleOrbitDomainRouteProxy(w http.ResponseWriter, r *http.Request) {
}
if status != "running" || portNum <= 0 {
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.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintf(w, `<!DOCTYPE html><html><body style="background:#090d16;color:#e2eaf2;font-family:sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;"><div style="text-align:center;"><h2>Application is %s</h2><p style="color:#64748b;">Start the container from the Orbit console to access it.</p><a href="/orbit" style="display:inline-block;margin-top:16px;color:#38bdf8;text-decoration:none;padding:8px 16px;border:1px solid rgba(56,189,248,0.3);border-radius:8px;">Open Orbit Console</a></div></body></html>`, status)
return
}