Fixed expiresAt value depending of cache hit/miss

This commit is contained in:
Linus Flood
2024-10-14 10:19:29 +02:00
parent a91c8ed928
commit 697d571ab2

View File

@@ -63,7 +63,12 @@ export const fetchAndCacheEntry = async (path: string, lang?: Lang) => {
}
const { contentType, uid } = await resolveEntry(path, lang)
const expiresAt = Date.now() / 1000 + 3600
let expiresAt = Date.now() / 1000
if (!contentType || !uid) {
expiresAt += 600
} else {
expiresAt += 3600 * 12
}
const entryCache = { contentType, uid, expiresAt }
size += JSON.stringify(entryCache).length
console.log("[CMS MIDDLEWARE] Adding to cache", entryCache)