diff --git a/src/middleware/pageCaching.ts b/src/middleware/pageCaching.ts index ce21bca..78f7e66 100644 --- a/src/middleware/pageCaching.ts +++ b/src/middleware/pageCaching.ts @@ -8,10 +8,14 @@ export const pageCachingMiddleware = defineMiddleware(async ({ url, request, loc const cachedPage = pageCache.get(pathname); if (cachedPage) { - const modifiedSince = request.headers.get("If-Modified-Since"); - const lastModified = cachedPage.headers.get("Last-Modified"); + const clientTimestamp = request.headers.get("If-Modified-Since"); + const serverTimestamp = cachedPage.headers.get("Last-Modified"); - if (modifiedSince && lastModified && new Date(modifiedSince) <= new Date(lastModified)) { + if ( + clientTimestamp && + serverTimestamp && + new Date(clientTimestamp) == new Date(serverTimestamp) + ) { return new Response(null, { status: 304, statusText: "Not Modified" }); }