diff --git a/internal/api/headers.go b/internal/api/headers.go index 46788d531..9014d449a 100644 --- a/internal/api/headers.go +++ b/internal/api/headers.go @@ -25,6 +25,11 @@ func AddCacheHeader(c *gin.Context, maxAge MaxAge) { c.Header("Cache-Control", fmt.Sprintf("private, max-age=%s, no-transform", maxAge)) } +// AddCoverCacheHeader adds cover image cache control headers to the response. +func AddCoverCacheHeader(c *gin.Context) { + AddCacheHeader(c, CoverCacheTTL) +} + // AddCacheHeader adds thumbnail cache control headers to the response. func AddThumbCacheHeader(c *gin.Context) { c.Header("Cache-Control", fmt.Sprintf("private, max-age=%s, no-transform, immutable", ThumbCacheTTL)) diff --git a/internal/api/thumbs.go b/internal/api/thumbs.go index 09c38fcc6..45b1a5225 100644 --- a/internal/api/thumbs.go +++ b/internal/api/thumbs.go @@ -257,7 +257,7 @@ func AlbumThumb(router *gin.RouterGroup) { // Use original file if thumb size exceeds limit, see https://github.com/photoprism/photoprism/issues/157 if thumbType.ExceedsSizeUncached() && c.Query("download") == "" { log.Debugf("album-thumbs: using original, size exceeds limit (width %d, height %d)", thumbType.Width, thumbType.Height) - AddThumbCacheHeader(c) + AddCoverCacheHeader(c) c.File(fileName) return } @@ -285,7 +285,7 @@ func AlbumThumb(router *gin.RouterGroup) { log.Debugf("cached %s [%s]", cacheKey, time.Since(start)) } - AddThumbCacheHeader(c) + AddCoverCacheHeader(c) if c.Query("download") != "" { c.FileAttachment(thumbnail, f.ShareBase()) @@ -341,7 +341,7 @@ func LabelThumb(router *gin.RouterGroup) { return } - AddThumbCacheHeader(c) + AddCoverCacheHeader(c) if c.Query("download") != "" { c.FileAttachment(cached.FileName, cached.ShareName) @@ -376,7 +376,7 @@ func LabelThumb(router *gin.RouterGroup) { if thumbType.ExceedsSizeUncached() { log.Debugf("label-thumbs: using original, size exceeds limit (width %d, height %d)", thumbType.Width, thumbType.Height) - AddThumbCacheHeader(c) + AddCoverCacheHeader(c) c.File(fileName) return @@ -405,7 +405,7 @@ func LabelThumb(router *gin.RouterGroup) { log.Debugf("cached %s [%s]", cacheKey, time.Since(start)) } - AddThumbCacheHeader(c) + AddCoverCacheHeader(c) if c.Query("download") != "" { c.FileAttachment(thumbnail, f.ShareBase())