st
st
CDCloudflare Developers
Created by Isaac on 11/28/2023 in #workers-help
cache miss due to fetch redirect?
hello Isaac, did you find a solution?
2 replies
CDCloudflare Developers
Created by Alek on 4/24/2024 in #functions
It seems like I always get a MISS for
hi alek, did you find a solution for this?
1 replies
CDCloudflare Developers
Created by Khafra on 7/2/2024 in #workers-help
check if fetch request returned a cached response?
console.log( Cache Status ${response.headers.get("CF-Cache-Status")} );
2 replies
CDCloudflare Developers
Created by st on 7/3/2024 in #next-on-pages
Caching issues
It's like this:
const SUSPENSE_CACHE_URL = "awesome.local";

const buildCacheKey = (key: string) => {
return `https://${SUSPENSE_CACHE_URL}/entry/${key}`;
};

export const cachedFetch = async (
name: string,
key: string,
age: number,
fetcher: () => Promise<Response>,
processor?: (response: Response) => Promise<Response>
) => {
const cache = await caches.open(name);

let response = await cache.match(buildCacheKey(key));

if (response === undefined) {
response = await fetcher();

if (processor) {
response = await processor(response);
}

response.headers.append("Cache-Control", `s-maxage=${age}`);

getRequestContext().ctx.waitUntil(
cache.put(buildCacheKey(key), response.clone())
);
}

return (await response.json()) as unknown;
};
const SUSPENSE_CACHE_URL = "awesome.local";

const buildCacheKey = (key: string) => {
return `https://${SUSPENSE_CACHE_URL}/entry/${key}`;
};

export const cachedFetch = async (
name: string,
key: string,
age: number,
fetcher: () => Promise<Response>,
processor?: (response: Response) => Promise<Response>
) => {
const cache = await caches.open(name);

let response = await cache.match(buildCacheKey(key));

if (response === undefined) {
response = await fetcher();

if (processor) {
response = await processor(response);
}

response.headers.append("Cache-Control", `s-maxage=${age}`);

getRequestContext().ctx.waitUntil(
cache.put(buildCacheKey(key), response.clone())
);
}

return (await response.json()) as unknown;
};
2 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
by the way, i did deploy the same app using next.js, it's much worse 😄
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
thanks anyway
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
i can do that, but i need ssr for seo,
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
that's right
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
algolia'a react library makes the api calls internally
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
Subrequests: "Requests triggered by calling fetch from within your Functions."
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
but isn't this will be same with Subrequests
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
to a worker i guess,
129 replies
CDCloudflare Developers
Created by st on 6/23/2024 in #pages-help
Unstable Response Times
i can proxy the algolia requests,
129 replies