2022-09-14 05:28:31 +00:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
2023-01-18 15:02:59 +00:00
|
|
|
"github.com/fthvgb1/wp-go/helper"
|
2022-09-14 05:28:31 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func SetStaticFileCache(c *gin.Context) {
|
|
|
|
f := strings.Split(strings.TrimLeft(c.FullPath(), "/"), "/")
|
2022-09-23 13:58:24 +00:00
|
|
|
if len(f) > 0 && helper.IsContainInArr(f[0], []string{"wp-includes", "wp-content", "favicon.ico"}) {
|
2022-09-14 05:28:31 +00:00
|
|
|
c.Header("Cache-Control", "private, max-age=86400")
|
|
|
|
}
|
2022-09-14 13:30:59 +00:00
|
|
|
c.Next()
|
2022-09-14 05:28:31 +00:00
|
|
|
}
|