diff --git a/backend/init/router/router.go b/backend/init/router/router.go index 4517f40f9..ebcd39b8a 100644 --- a/backend/init/router/router.go +++ b/backend/init/router/router.go @@ -4,6 +4,7 @@ import ( "github.com/gin-contrib/gzip" "html/template" "net/http" + "strings" "github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/i18n" @@ -19,6 +20,12 @@ import ( func setWebStatic(rootRouter *gin.RouterGroup) { rootRouter.StaticFS("/public", http.FS(web.Favicon)) + rootRouter.Use(func(c *gin.Context) { + if strings.HasPrefix(c.Request.URL.Path, "/assets/") { + c.Header("Cache-Control", "max-age=31536000") + } + c.Next() + }) rootRouter.GET("/assets/*filepath", func(c *gin.Context) { staticServer := http.FileServer(http.FS(web.Assets)) staticServer.ServeHTTP(c.Writer, c.Request)