Make gallery cache time configurable
This commit is contained in:
+2
-1
@@ -42,7 +42,8 @@
|
||||
"singleItemAutoOpen": true,
|
||||
"showTitle": true,
|
||||
"showDescription": false,
|
||||
"groupByDate": false
|
||||
"groupByDate": false,
|
||||
"cacheTime": 300
|
||||
},
|
||||
"lightbox": {
|
||||
"showArrows": true,
|
||||
|
||||
@@ -49,7 +49,6 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
|
||||
const descriptionInSidebar = shareMetadataAllowed && !!getConfigOption('ipp.showMetadata.description.sidebar', false)
|
||||
const sidebarHasContent = shareMetadataAllowed && (descriptionInSidebar || metadataGroupActive('exif') || metadataGroupActive('location'))
|
||||
|
||||
// Build structured items in parallel
|
||||
const items: GalleryItem[] = await Promise.all(share.assets.map(async (asset): Promise<GalleryItem> => {
|
||||
let videoData: string | undefined
|
||||
if (asset.type === AssetType.video) {
|
||||
@@ -159,9 +158,10 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
|
||||
metaBase
|
||||
}
|
||||
|
||||
// Always revalidate the HTML so it picks up new versioned asset URLs on
|
||||
// upgrade; the assets themselves are immutable-cached. (304s via ETag.)
|
||||
res.header('Cache-Control', 'no-cache')
|
||||
// HTML gallery page cache time
|
||||
const configured = Number(getConfigOption('ipp.gallery.cacheTime', 300))
|
||||
const cacheTime = Number.isFinite(configured) ? Math.max(0, configured) : 300
|
||||
res.header('Cache-Control', 'public, max-age=' + cacheTime)
|
||||
res.send(renderPage(h(Gallery, props)))
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ Options that control how the gallery page is rendered. Configured under `ipp.gal
|
||||
| `showTitle` | `bool` | Show a title on the gallery page. This is taken from the album title if it is an album being shared, otherwise the "Description" from the shared link will be used. |
|
||||
| `showDescription` | `bool` | Show the album description below the title. This only applies if it is an album which is being shared. |
|
||||
| `groupByDate` | `bool` | Group the gallery's thumbnails by month, with headers like "December 2024" above each group. Sorts photos newest-first. Items missing a creation date end up under an "Undated" bucket at the end (or render without any header when the whole gallery is undated). **Requires "Show metadata" to be enabled on the share in Immich** - when that's off, Immich strips creation dates from the assets it returns to IPP, so grouping won't work. Default `false`. |
|
||||
| `cacheTime` | `int` | How long (in seconds) browsers and any CDN may cache the gallery **page** before revalidating. Set this longer to reduce load on your server, but be aware that if you add new photos to a gallery they won't show up until the cache times out or you manually clear any downstream caches. |
|
||||
|
||||
Example: show the gallery title and group photos by month.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user