mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-08 02:03:42 +08:00
opt: optimize image compress alg, add cache control for image
This commit is contained in:
@@ -336,9 +336,11 @@ func staticResourceMiddleware() gin.HandlerFunc {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// 设置图片缓存有效期为一年 (365天)
|
||||
c.Header("Cache-Control", "max-age=31536000, public")
|
||||
// 直接输出图像数据流
|
||||
c.Data(http.StatusOK, "image/jpeg", buffer.Bytes())
|
||||
return
|
||||
c.Abort() // 中断请求
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user