summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-07-10 19:02:32 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-07-10 19:02:32 +0200
commit358bf873296d4d4e84611d3f3d5ae48eabfc8ad6 (patch)
treea24472a43aa4e19264e128d45fb37695eb803b50
parent:wheelchair: use fs sync for backwards compatiblity (diff)
downloadserver-358bf873296d4d4e84611d3f3d5ae48eabfc8ad6.tar.xz
:zap: cache assets
-rw-r--r--src/routes/attachments.ts1
-rw-r--r--src/routes/avatars.ts1
-rw-r--r--src/start.ts5
3 files changed, 6 insertions, 1 deletions
diff --git a/src/routes/attachments.ts b/src/routes/attachments.ts

index 2e635b43..acc7604d 100644 --- a/src/routes/attachments.ts +++ b/src/routes/attachments.ts
@@ -52,6 +52,7 @@ router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) => const type = await FileType.fromBuffer(file); res.set("Content-Type", type?.mime); + res.set("Cache-Control", "public, max-age=31536000"); return res.send(file); }); diff --git a/src/routes/avatars.ts b/src/routes/avatars.ts
index 321ae02e..fea7c5f4 100644 --- a/src/routes/avatars.ts +++ b/src/routes/avatars.ts
@@ -52,6 +52,7 @@ router.get("/:user_id/:id", async (req: Request, res: Response) => { const type = await FileType.fromBuffer(file); res.set("Content-Type", type?.mime); + res.set("Cache-Control", "public, max-age=31536000"); return res.send(file); }); diff --git a/src/start.ts b/src/start.ts
index 54228a5f..822a749f 100644 --- a/src/start.ts +++ b/src/start.ts
@@ -7,7 +7,10 @@ if (process.env.STORAGE_LOCATION) { if (!process.env.STORAGE_LOCATION.startsWith("/")) { process.env.STORAGE_LOCATION = __dirname + "/../" + process.env.STORAGE_LOCATION; } -} else process.env.STORAGE_LOCATION = __dirname + "/../files/"; +} else { + process.env.STORAGE_LOCATION = __dirname + "/../files/"; + process.env.STORAGE_PROVIDER = "file"; +} const server = new CDNServer({ port: Number(process.env.PORT) || 3003 }); server