export const loader = async ({ request, context }: LoaderFunctionArgs) => {
let cache = caches.default;
const data = await cache.match(request);
if (data) return data;
const time = new Date().toLocaleTimeString();
const response = json(
{ time },
{
headers: {
"Cache-Control": "public, max-age=5, s-maxage=10",
},
}
);
const cachedData = await cache.put(request, response.clone());
console.log("cachedData", cachedData);
return response;
};`
export const loader = async ({ request, context }: LoaderFunctionArgs) => {
let cache = caches.default;
const data = await cache.match(request);
if (data) return data;
const time = new Date().toLocaleTimeString();
const response = json(
{ time },
{
headers: {
"Cache-Control": "public, max-age=5, s-maxage=10",
},
}
);
const cachedData = await cache.put(request, response.clone());
console.log("cachedData", cachedData);
return response;
};`