19 lines
495 B
Go
19 lines
495 B
Go
|
|
package middleware
|
||
|
|
|
||
|
|
import "github.com/gin-gonic/gin"
|
||
|
|
|
||
|
|
const (
|
||
|
|
CacheControlList = "public, max-age=300, s-maxage=1800, stale-while-revalidate=60"
|
||
|
|
CacheControlCurve = "public, max-age=300, s-maxage=3600, stale-while-revalidate=120"
|
||
|
|
CacheControlModelList = "public, max-age=30, s-maxage=300, stale-while-revalidate=30"
|
||
|
|
)
|
||
|
|
|
||
|
|
func CacheControl(value string) gin.HandlerFunc {
|
||
|
|
return func(c *gin.Context) {
|
||
|
|
c.Header("Cache-Control", value)
|
||
|
|
c.Header("Vary", "Accept-Encoding")
|
||
|
|
c.Next()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|