From ed14d1ebd7c8d9428ac58b3a6280e3df6686aec1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 5 Jun 2023 10:05:49 +0200 Subject: Invalidate cache feed even after server restart --- server/middlewares/cache/shared/api-cache.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'server/middlewares') diff --git a/server/middlewares/cache/shared/api-cache.ts b/server/middlewares/cache/shared/api-cache.ts index c6197b972..b50b7dce4 100644 --- a/server/middlewares/cache/shared/api-cache.ts +++ b/server/middlewares/cache/shared/api-cache.ts @@ -35,7 +35,11 @@ export class ApiCache { // Cache keys per group private groups: { [groupIndex: string]: string[] } = {} + private readonly seed: number + constructor (options: APICacheOptions) { + this.seed = new Date().getTime() + this.options = { headerBlacklist: [], excludeStatus: [], @@ -88,7 +92,7 @@ export class ApiCache { } private getCacheKey (req: express.Request) { - return Redis.Instance.getPrefix() + 'api-cache-' + req.originalUrl + return Redis.Instance.getPrefix() + 'api-cache-' + this.seed + '-' + req.originalUrl } private shouldCacheResponse (response: express.Response) { -- cgit v1.2.3