API: Add Explicit Cache Header for Existing Thumbs #822

This commit is contained in:
Michael Mayer
2022-02-20 17:36:51 +01:00
parent a9193c47a9
commit 6c4fc42415
25 changed files with 28 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
Package acl contains PhotoPrism's access control lists for authorizing user actions. Package acl contains PhotoPrism's access control lists for authorizing user actions.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package api contains PhotoPrism REST API handlers. Package api contains PhotoPrism REST API handlers.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -63,11 +63,10 @@ func GetThumb(router *gin.RouterGroup) {
return return
} }
AddThumbCacheHeader(c)
if download { if download {
c.FileAttachment(fileName, cropName.Jpeg()) c.FileAttachment(fileName, cropName.Jpeg())
} else { } else {
AddThumbCacheHeader(c)
c.File(fileName) c.File(fileName)
} }
@@ -108,11 +107,10 @@ func GetThumb(router *gin.RouterGroup) {
return return
} }
AddThumbCacheHeader(c)
if c.Query("download") != "" { if c.Query("download") != "" {
c.FileAttachment(cached.FileName, cached.ShareName) c.FileAttachment(cached.FileName, cached.ShareName)
} else { } else {
AddThumbCacheHeader(c)
c.File(cached.FileName) c.File(cached.FileName)
} }
@@ -122,6 +120,7 @@ func GetThumb(router *gin.RouterGroup) {
// Return existing thumbs straight away. // Return existing thumbs straight away.
if !download { if !download {
if fileName, err := thumb.FileName(fileHash, conf.ThumbPath(), size.Width, size.Height, size.Options...); err == nil && fs.FileExists(fileName) { if fileName, err := thumb.FileName(fileHash, conf.ThumbPath(), size.Width, size.Height, size.Options...); err == nil && fs.FileExists(fileName) {
AddThumbCacheHeader(c)
c.File(fileName) c.File(fileName)
return return
} }
@@ -202,11 +201,10 @@ func GetThumb(router *gin.RouterGroup) {
cache.SetDefault(cacheKey, ThumbCache{thumbnail, f.ShareBase(0)}) cache.SetDefault(cacheKey, ThumbCache{thumbnail, f.ShareBase(0)})
log.Debugf("cached %s [%s]", cacheKey, time.Since(start)) log.Debugf("cached %s [%s]", cacheKey, time.Since(start))
AddThumbCacheHeader(c)
if download { if download {
c.FileAttachment(thumbnail, f.DownloadName(DownloadName(c), 0)) c.FileAttachment(thumbnail, f.DownloadName(DownloadName(c), 0))
} else { } else {
AddThumbCacheHeader(c)
c.File(thumbnail) c.File(thumbnail)
} }
}) })

View File

@@ -2,7 +2,7 @@
Package auto contains index & import background workers. Package auto contains index & import background workers.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package classify encapsulates image classification using TensorFlow. Package classify encapsulates image classification using TensorFlow.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package crop provides image crop data structures and helpers. Package crop provides image crop data structures and helpers.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package face provides facial recognition. Package face provides facial recognition.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package form contains tagged structs for input value validation. Package form contains tagged structs for input value validation.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package hub contains backend api config & clients. Package hub contains backend api config & clients.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package places encapsulates the PhotoPrism Places geolocation API. Package places encapsulates the PhotoPrism Places geolocation API.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package i18n contains PhotoPrism status and error message strings. Package i18n contains PhotoPrism status and error message strings.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package maps encapsulates external geolocation APIs. Package maps encapsulates external geolocation APIs.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package meta encapsulates image metadata decoding and conversion to/from XMP and Exif. Package meta encapsulates image metadata decoding and conversion to/from XMP and Exif.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package migrate provides database schema migrations. Package migrate provides database schema migrations.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package nsfw uses TensorFlow to detect images that may not be safe for work. Package nsfw uses TensorFlow to detect images that may not be safe for work.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package photoprism contains PhotoPrism core functionality. Package photoprism contains PhotoPrism core functionality.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package query provides frequently used database queries for use in commands and API. Package query provides frequently used database queries for use in commands and API.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -5,7 +5,7 @@ Package remote implements remote service sync and uploads.
See also: See also:
- RClone (https://rclone.org/), a popular Go tool for syncing data with remote services - RClone (https://rclone.org/), a popular Go tool for syncing data with remote services
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package webdav implements sharing with WebDAV servers. Package webdav implements sharing with WebDAV servers.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package search performs common index search queries. Package search performs common index search queries.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package session provides session storage and management. Package session provides session storage and management.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package thumb provides JPEG resampling and thumbnail generation. Package thumb provides JPEG resampling and thumbnail generation.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package video provides video file related types and functions. Package video provides video file related types and functions.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package viewer provides photo viewer data structures and utility functions. Package viewer provides photo viewer data structures and utility functions.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published

View File

@@ -2,7 +2,7 @@
Package workers contains background workers for file sync & metadata optimization. Package workers contains background workers for file sync & metadata optimization.
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.org> Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published it under the terms of the GNU Affero General Public License as published