Use cache for ttl if possible

Also fixes etag when compression enabled
This commit is contained in:
Ajay
2024-04-11 17:54:32 -04:00
parent 7c77bf566e
commit 0602fdd651
3 changed files with 11 additions and 1 deletions

View File

@@ -143,6 +143,7 @@ async function getKeyLastModified(key: string): Promise<Date> {
if (!config.redis?.enabled) return Promise.reject("ETag - Redis not enabled");
return await redis.ttl(key)
.then(ttl => {
if (ttl <= 0) return new Date();
const sinceLive = config.redis?.expiryTime - ttl;
const now = Math.floor(Date.now() / 1000);
return new Date((now-sinceLive) * 1000);