perf: 优化上传文件缓存策略
- 上传新文件时删除同类型旧文件,避免文件堆积 - 文件名带时间戳,每次上传生成新 URL - 缓存时间设为 1 年 + immutable,文件更新后 URL 变化自动重新请求
This commit is contained in:
+1
-1
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user