From 9370bdb5ac740ab59a9cde6e4b0507bbfe367ce6 Mon Sep 17 00:00:00 2001 From: KOMATA <20227709+HynoR@users.noreply.github.com> Date: Fri, 21 Nov 2025 15:47:48 +0800 Subject: [PATCH] fix: Update Cache-Control headers for static resources in router (#11020) * fix: Update Cache-Control headers for static resources in router * chore: Remove Cache-Control header from static resource response in router --- core/init/router/router.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/init/router/router.go b/core/init/router/router.go index 975162224..8575eba00 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 @@ -137,7 +136,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)