From f07c81834215ae1d43fe64af5466625411a7e6ac Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:06:59 +0800 Subject: [PATCH 1/2] fix: Update Cache-Control headers for static resources in router --- core/init/router/router.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/init/router/router.go b/core/init/router/router.go index 975162224ec5..836f6ccb1542 100644 --- a/core/init/router/router.go +++ b/core/init/router/router.go @@ -2,7 +2,6 @@ package router import ( "encoding/base64" - "fmt" "io" "net/http" "os" @@ -33,7 +32,7 @@ func setWebStatic(rootRouter *gin.RouterGroup) { RegisterImages(rootRouter) setStaticResource(rootRouter) rootRouter.GET("/assets/*filepath", func(c *gin.Context) { - c.Writer.Header().Set("Cache-Control", fmt.Sprintf("private, max-age=%d", 2628000)) + c.Writer.Header().Set("Cache-Control", "private, max-age=2628000, immutable") if c.Request.URL.Path[len(c.Request.URL.Path)-1] == '/' { c.AbortWithStatus(http.StatusForbidden) return @@ -62,6 +61,7 @@ func setWebStatic(rootRouter *gin.RouterGroup) { entranceValue := base64.StdEncoding.EncodeToString([]byte(entrance)) c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true) } + c.Writer.Header().Set("Cache-Control", "private, max-age=0, must-revalidate") staticServer := http.FileServer(http.FS(web.IndexHtml)) staticServer.ServeHTTP(c.Writer, c.Request) }) @@ -137,7 +137,7 @@ func RegisterImages(rootRouter *gin.RouterGroup) { func setStaticResource(rootRouter *gin.RouterGroup) { rootRouter.GET("/api/v2/static/*filename", func(c *gin.Context) { - c.Writer.Header().Set("Cache-Control", fmt.Sprintf("private, max-age=%d", 2628000)) + c.Writer.Header().Set("Cache-Control", "private, max-age=2628000") filename := c.Param("filename") filePath := "static" + filename data, err := web.Static.ReadFile(filePath) From 464c9fa01979644c1d7c5448d068b11ad0bf14e8 Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:14:52 +0800 Subject: [PATCH 2/2] chore: Remove Cache-Control header from static resource response in router --- core/init/router/router.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/init/router/router.go b/core/init/router/router.go index 836f6ccb1542..8575eba00929 100644 --- a/core/init/router/router.go +++ b/core/init/router/router.go @@ -61,7 +61,6 @@ func setWebStatic(rootRouter *gin.RouterGroup) { entranceValue := base64.StdEncoding.EncodeToString([]byte(entrance)) c.SetCookie("SecurityEntrance", entranceValue, 0, "", "", false, true) } - c.Writer.Header().Set("Cache-Control", "private, max-age=0, must-revalidate") staticServer := http.FileServer(http.FS(web.IndexHtml)) staticServer.ServeHTTP(c.Writer, c.Request) })