feat: update html cache

This commit is contained in:
engigu
2024-01-02 14:45:34 +08:00
parent 599999b6bf
commit e26932d02c
3 changed files with 55 additions and 35 deletions
+18
View File
@@ -0,0 +1,18 @@
package middleware
import (
"github.com/gin-gonic/gin"
"strings"
)
// StaticCacheMiddleware add embed file static cache
func StaticCacheMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
// Apply the Cache-Control header to the static files
if strings.HasPrefix(c.Request.URL.Path, "/assets/") {
c.Header("Cache-Control", "private, max-age=86400")
}
// Continue to the next middleware or handler
c.Next()
}
}