chore: auto-commit (23 archivos)
- app.md - backend/dist/assets/index-CFDWXN9Z.js - backend/dist/index.html - backend/handlers.go - backend/main.go - backend/users.go - e2e/smoke_live.sh - frontend/src/App.tsx - frontend/src/api.ts - frontend/src/components/CardChatPanel.tsx - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+28
-2
@@ -69,7 +69,10 @@ func main() {
|
||||
logger := newChatLogger(filepath.Join(wd, "chat.log"))
|
||||
log.Printf("chat tool log: %s", logger.path)
|
||||
hub := NewEventHub()
|
||||
mux := infra.HTTPRouter(apiRoutes(db, wd, logger, internalToken, &featureFlags, hub))
|
||||
dispatcher := NewDispatcher(db, hub)
|
||||
dispatcher.Start()
|
||||
defer dispatcher.Stop()
|
||||
mux := infra.HTTPRouter(apiRoutes(db, wd, logger, internalToken, &featureFlags, hub, dispatcher))
|
||||
|
||||
feHandler := frontendHandler()
|
||||
if feHandler != nil {
|
||||
@@ -169,5 +172,28 @@ func frontendHandler() http.Handler {
|
||||
if len(entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
return infra.SPAHandler(sub, "index.html")
|
||||
return cacheHeadersMiddleware(infra.SPAHandler(sub, "index.html"))
|
||||
}
|
||||
|
||||
// cacheHeadersMiddleware ensures the SPA shell is never cached while the
|
||||
// hashed assets (which are content-addressed by Vite) are cached for a long
|
||||
// time. Without this, browsers happily reuse an old index.html — pinned to a
|
||||
// stale /assets/index-<hash>.js URL — and never pick up new releases.
|
||||
//
|
||||
// Policy:
|
||||
//
|
||||
// /assets/* → public, max-age=1y, immutable (filename changes per build)
|
||||
// everything else → no-store, must-revalidate (forces revalidation on every
|
||||
// navigation so the latest hash is always discovered)
|
||||
func cacheHeadersMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if strings.HasPrefix(r.URL.Path, "/assets/") {
|
||||
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
|
||||
} else {
|
||||
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate")
|
||||
w.Header().Set("Pragma", "no-cache")
|
||||
w.Header().Set("Expires", "0")
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user