Add caching

This commit is contained in:
Alan Grainger
2024-10-29 16:15:34 +01:00
parent b5ee0a1429
commit 43e038078e
5 changed files with 12 additions and 1 deletions
+2
View File
@@ -16,6 +16,7 @@ const getSize = (req: Request) => {
}
app.get('/share/:key', async (req, res) => {
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE)
if (!immich.isKey(req.params.key)) {
res.status(404).send()
} else {
@@ -41,6 +42,7 @@ app.get('/share/:key', async (req, res) => {
// Output the buffer data for an photo or video
app.get('/:type(photo|video)/:key/:id', async (req, res) => {
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE)
// Check for valid key and ID
if (immich.isKey(req.params.key) && immich.isId(req.params.id)) {
// Check if the key is a valid share link