New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Miniflare sets CF-Cache-Status
to null on misses
#4379
Comments
Hey! 👋 Could I clarify, is this when using the |
Hey, sorry for being so sparse on detail in this issue. The code is essentially: export async function handleRequest(request: Request, ctx: ExecutionContext) {
// ... cache key computation ...
// Try to fetch the item from the cache
const cache = caches.default
let response
response = await cache.match(cacheKey)
if (!response) {
response = await fetchAndPotentiallyCache({
request,
cacheKey,
ctx,
})
}
response = new Response(response.body, response)
// Done
return response
}
export async function fetchAndPotentiallyCache({
request,
cacheKey,
ctx,
}: {
request: Request
cacheKey: string
ctx: ExecutionContext
}): Promise<Response> {
let response = await fetch(request, {
cf: {
cacheEverything: true
},
})
response = new Response(response.body, response)
response.headers.set(
"Cache-Control",
`s-maxage=60`,
)
// This is a small workaround for miniflare
// TODO remove once https://github.com/cloudflare/miniflare/issues/82 is fixed
const cloned = response.clone()
ctx.waitUntil(
caches.default
.delete(cacheKey)
.then(() => caches.default.put(cacheKey, cloned)),
)
return response
} When we get a cache hit in |
Hey! 👋 Apologies for the delayed follow up. I'm going to transfer this to |
Contrary to cloudflare's behavior, miniflare does not set
CF-Cache-Status
when the cache was a miss.Cloudflare however returns the header with
MISS
:The text was updated successfully, but these errors were encountered: