Fixed If modfied since logic
This commit is contained in:
parent
cbbf0e5e3b
commit
246cdb4af0
|
@ -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" });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue