diff --git a/backend/cmd/main.go b/backend/cmd/main.go index c0f3b5e..8984b33 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -233,7 +233,7 @@ func startServer() { r.Use(func(c *gin.Context) { if strings.HasPrefix(c.Request.URL.Path, "/uploads/") { - c.Header("Cache-Control", "public, max-age=3600") + c.Header("Cache-Control", "public, max-age=31536000, immutable") } c.Next() }) diff --git a/backend/internal/router/admin/system_settings.go b/backend/internal/router/admin/system_settings.go index 2b8a0ba..aa1d23d 100644 --- a/backend/internal/router/admin/system_settings.go +++ b/backend/internal/router/admin/system_settings.go @@ -382,6 +382,12 @@ func handleUploadSystemImage(c *gin.Context) { return } + pattern := filepath.Join(uploadDir, uploadType+"_*") + oldFiles, _ := filepath.Glob(pattern) + for _, oldFile := range oldFiles { + os.Remove(oldFile) + } + filename := fmt.Sprintf("%s_%d%s", uploadType, time.Now().UnixNano(), ext) filePath := filepath.Join(uploadDir, filename)