From e0b02b86ecd71b236a52f3f4a6a9b94c00c75b59 Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Thu, 3 Sep 2020 22:48:19 +0200 Subject: [PATCH] feat: set express_redis_cache_name in home or other routes --- src/app.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 696e6d1..cb6ad81 100644 --- a/src/app.ts +++ b/src/app.ts @@ -101,6 +101,7 @@ let main = async () => { app.get( '/', (req, res, next) => { + res.express_redis_cache_name = req.path if (process.env.OPEN_DATE == null) { next() return @@ -124,10 +125,19 @@ let main = async () => { cache.route('/home', cacheDuration.home), PublicController.home ) - app.get('/c', cache.route('/c', cacheDuration.countdown), PublicController.countdown) + app.get( + '/c', + (req, res, next) => { + res.express_redis_cache_name = req.path + next() + }, + cache.route('/c', cacheDuration.countdown), + PublicController.countdown + ) app.get( '/association/:slug', (req, res, next) => { + res.express_redis_cache_name = req.path // disable cache if proposed in query let isProposed = Utils.isStrUsable(req.query, 'version') if (isProposed) {