mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
cache
This commit is contained in:
parent
337bd8e896
commit
c90388f0c9
1 changed files with 17 additions and 17 deletions
|
|
@ -19,23 +19,23 @@ export default function handleRequest(
|
||||||
responseHeaders: Headers,
|
responseHeaders: Headers,
|
||||||
remixContext: EntryContext
|
remixContext: EntryContext
|
||||||
) {
|
) {
|
||||||
// console.log(request.url);
|
console.log(request.url);
|
||||||
// // check if we have a cached response in memory
|
// check if we have a cached response in memory
|
||||||
// const cachedResponse = cache.get(request.url);
|
const cachedResponse = cache.get(request.url);
|
||||||
// if (cachedResponse) {
|
if (cachedResponse) {
|
||||||
// console.log('Serving from cache', request.url);
|
console.log('Serving from cache', request.url);
|
||||||
// // if we have a cached response, check if it's less than 5 seconds old
|
// if we have a cached response, check if it's less than 5 seconds old
|
||||||
// const now = new Date();
|
const now = new Date();
|
||||||
// const diff = now.getTime() - cachedResponse.date.getTime();
|
const diff = now.getTime() - cachedResponse.date.getTime();
|
||||||
// if (true || diff < 5000) {
|
if (true || diff < 5000) {
|
||||||
// // if it's less than 5 seconds old, return the cached response
|
// if it's less than 5 seconds old, return the cached response
|
||||||
// responseHeaders.set('Content-Type', 'text/html');
|
responseHeaders.set('Content-Type', 'text/html');
|
||||||
// return new Response(cachedResponse.html, {
|
return new Response(cachedResponse.html, {
|
||||||
// headers: responseHeaders,
|
headers: responseHeaders,
|
||||||
// status: responseStatusCode,
|
status: responseStatusCode,
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue