> So i am expecting for the same request

So i am expecting for the same request with in my window of an hr, the 2nd fetch response would be taken from the cache not go to make another http request correct ?
Cache by default is per colo/cf dc, and some Cloudflare Points of Presence even have multiple colos, so you might be routed to a different one/different visitors will certainly be, and get MISS's, plus TTL is just a max and CF may evict it far before then based on access frequency.
if this is the case why for every fetch request i do the worker gets called and returns the response?
The worker will always be invocation/run on every request, even if using cache
How can i validate that this is from the cache or not?
Check response headers for CF-Cache-Status
10 Replies
Nehal Ali
Nehal Ali7mo ago
Thank you for your response, i tried to check for CF-Cache-Status header and it returns back null . any idea what might be causing this ?
Chaika
Chaika7mo ago
how are you returning the response? If you're just returning it directly return fetch(...) then those headers should be in your response headers in the browser as well, easier to debug with
Nehal Ali
Nehal Ali7mo ago
const modifiedRequest = new Request( env.auth_url, { method: 'POST', headers: originalHeaders, }); // Call fetch with the new request and cache configuration const response = await fetch(modifiedRequest, { cf: { cacheTtl: 3600, cacheEverything: true }, }); yes i using the response returned from the fetch but the headers give me an empty obj
Chaika
Chaika7mo ago
cacheEverything applies to only GET and HEAD
This option applies to GET and HEAD request methods only.
Chaika
Chaika7mo ago
Cloudflare Docs
Cache POST requests · Cloudflare Workers docs
Documentation for Cloudflare Workers, a serverless execution environment that allows you to create entirely new applications or augment existing ones …
Nehal Ali
Nehal Ali7mo ago
i adjusted the code to fetch with the get to try things out and it gives the same result. The fetch result is correct but cf-cache-status is still null
No description
Chaika
Chaika7mo ago
What's the URL to, something on your website or external?
Nehal Ali
Nehal Ali7mo ago
the url is a my worker.dev url
Chaika
Chaika7mo ago
late response but there's no cache on those/workers are always going to run in front of cache
Nehal Ali
Nehal Ali7mo ago
got it . thanks
Want results from more Discord servers?
Add your server