2023-04-22 12:39:27 +00:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Cache() func(c *gin.Context) {
|
|
|
|
return func(c *gin.Context) {
|
2023-05-21 16:54:53 +00:00
|
|
|
if c.Request.RequestURI == "/" {
|
|
|
|
c.Header("Cache-Control", "no-cache")
|
|
|
|
} else {
|
|
|
|
c.Header("Cache-Control", "max-age=604800") // one week
|
|
|
|
}
|
2023-04-22 12:39:27 +00:00
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|