fix: cache error

This commit is contained in:
monoid 2023-10-26 22:09:20 +09:00
parent 454850c6b3
commit 22fad337ae

View File

@ -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});
},
};