aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/cache.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/cache.ts')
-rw-r--r--server/middlewares/cache.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts
index e83d8d569..091c82d92 100644
--- a/server/middlewares/cache.ts
+++ b/server/middlewares/cache.ts
@@ -7,6 +7,8 @@ import { logger } from '../helpers/logger'
7const lock = new AsyncLock({ timeout: 5000 }) 7const lock = new AsyncLock({ timeout: 5000 })
8 8
9function cacheRoute (lifetimeArg: string | number) { 9function cacheRoute (lifetimeArg: string | number) {
10 const lifetime = parseDurationToMs(lifetimeArg)
11
10 return async function (req: express.Request, res: express.Response, next: express.NextFunction) { 12 return async function (req: express.Request, res: express.Response, next: express.NextFunction) {
11 const redisKey = Redis.Instance.generateCachedRouteKey(req) 13 const redisKey = Redis.Instance.generateCachedRouteKey(req)
12 14
@@ -24,7 +26,6 @@ function cacheRoute (lifetimeArg: string | number) {
24 res.send = (body) => { 26 res.send = (body) => {
25 if (res.statusCode >= 200 && res.statusCode < 400) { 27 if (res.statusCode >= 200 && res.statusCode < 400) {
26 const contentType = res.get('content-type') 28 const contentType = res.get('content-type')
27 const lifetime = parseDurationToMs(lifetimeArg)
28 29
29 Redis.Instance.setCachedRoute(req, body, lifetime, contentType, res.statusCode) 30 Redis.Instance.setCachedRoute(req, body, lifetime, contentType, res.statusCode)
30 .then(() => done()) 31 .then(() => done())