It seems like I always get a MISS for
It seems like I always get a MISS for the same URL I want to cache. Is it something I'm missing? "try {
let url = await context.request.url;
let paramString = url.split('?')[1];
if (paramString.includes('ntt=') || paramString.includes('lpurl')) { const today = new Date(); const tomorrow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1); const seconds = Math.floor((tomorrow.getTime() + 18000000 - today.getTime()) / 1000); console.log(seconds); let response = await fetch(fetchUrl.concat('?', paramString), { method: "GET", cf: { cacheTtl: seconds, cacheEverything: true, cacheKey: url, }, }); let headersObject = Object.fromEntries(response.headers); let responseHeaders = JSON.stringify(headersObject, null, 2); console.log(
return response; } } catch (err) { return new Response('Error parsing JSON content', { status: 400 }); }"
if (paramString.includes('ntt=') || paramString.includes('lpurl')) { const today = new Date(); const tomorrow = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1); const seconds = Math.floor((tomorrow.getTime() + 18000000 - today.getTime()) / 1000); console.log(seconds); let response = await fetch(fetchUrl.concat('?', paramString), { method: "GET", cf: { cacheTtl: seconds, cacheEverything: true, cacheKey: url, }, }); let headersObject = Object.fromEntries(response.headers); let responseHeaders = JSON.stringify(headersObject, null, 2); console.log(
Response headers: ${responseHeaders}
);return response; } } catch (err) { return new Response('Error parsing JSON content', { status: 400 }); }"
1 Reply
hi alek, did you find a solution for this?