test cache

This commit is contained in:
Wes Bos 2023-02-21 14:26:32 -05:00
parent 565452d4a8
commit 237df0993b

View file

@ -26,14 +26,14 @@ export default function handleRequest(
// if we have a cached response, check if it's less than 5 seconds old
const now = new Date();
const diff = now.getTime() - cachedResponse.date.getTime();
// if (diff < 5000) {
// // if it's less than 5 seconds old, return the cached response
// responseHeaders.set('Content-Type', 'text/html');
// return new Response(cachedResponse.html, {
// headers: responseHeaders,
// status: responseStatusCode,
// });
// }
if (true || diff < 5000) {
// if it's less than 5 seconds old, return the cached response
responseHeaders.set('Content-Type', 'text/html');
return new Response(cachedResponse.html, {
headers: responseHeaders,
status: responseStatusCode,
});
}
}