photoprism/internal/api/cache.go
Michael Mayer 60499867af API: Add Cache-Control and X-Preview-Token headers #822 #846
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2021-01-07 22:55:50 +01:00

19 lines
350 B
Go

package api
import (
"fmt"
"github.com/gin-gonic/gin"
)
type MaxAge string
var (
CacheShort MaxAge = "3600"
CacheLong MaxAge = "86400"
)
// AddCacheHeader adds a cache control header to the response.
func AddCacheHeader(c *gin.Context, maxAge MaxAge) {
c.Header("Cache-Control", fmt.Sprintf("private, max-age=%s, no-transform", maxAge))
}