From 22fad337aefdd93a3da228dd4d6d0359f36dc89f Mon Sep 17 00:00:00 2001 From: monoid Date: Thu, 26 Oct 2023 22:09:20 +0900 Subject: [PATCH] fix: cache error --- routes/api/pages/[name].ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/routes/api/pages/[name].ts b/routes/api/pages/[name].ts index 499bf9c..b1a064d 100644 --- a/routes/api/pages/[name].ts +++ b/routes/api/pages/[name].ts @@ -25,16 +25,18 @@ export const handler: Handlers = { const mtime = stat.mtime ?? new Date(0); const body = await Deno.readTextFile(path); headers.set("last-modified", mtime.toUTCString()); + console.log(mtime); + // headers.set("cache-control", "max-age=600"); - const ifModifiedSinceValue = req.headers.get("if-modified-since"); - if ( ifModifiedSinceValue && - mtime.getTime() != new Date(ifModifiedSinceValue).getTime() - ){ - return new Response(null, { - status: Status.NotModified, - statusText: STATUS_TEXT[Status.NotModified] - }) - } + // const ifModifiedSinceValue = req.headers.get("if-modified-since"); + // if ( ifModifiedSinceValue && + // mtime.getTime() <= new Date(ifModifiedSinceValue).getTime() + // ){ + // return new Response(null, { + // status: Status.NotModified, + // statusText: STATUS_TEXT[Status.NotModified] + // }) + // } return new Response(body, {headers}); }, };