responses with "cf-cache-status: REVALIDATED" are being stored in cache following fetch()

Symptom: Edge worker consistently responds for some requests with cf-cache-status: REVALIDATED and no Age header. This happens until this resposne falls out of cache. It occurs randomly across various requests. Detail: I have an edge worker that is fetch()ing content from another site which is using cloudflare. Sometimes, a response from the origin has the header cf-cache-status: REVALIDATED. What appears to happen is that my edge worker appears to store this header in it's own cached response. Question: How can I ensure this response has cf-cache-status: HIT in the cache? As per my other post, this is tiered caching so I don't think I can modify the response and use cache.put()... Should I manually change it each time in the worker as a cludge? As such?
let originResponse = await fetch(request, options);
let response = new Response(originResponse.body, originResponse);
if (response.headers.get('cf-cache-status') == 'REVALIDATED') {
response.headers.delete('cf-cache-status');
response.headers.set('cf-cache-status', 'HIT');
// delete this cache so next time it is retried - but this supposedly won't work with a domain set up with tiered caching
cache.delete(cacheKeyUrl);
}
let originResponse = await fetch(request, options);
let response = new Response(originResponse.body, originResponse);
if (response.headers.get('cf-cache-status') == 'REVALIDATED') {
response.headers.delete('cf-cache-status');
response.headers.set('cf-cache-status', 'HIT');
// delete this cache so next time it is retried - but this supposedly won't work with a domain set up with tiered caching
cache.delete(cacheKeyUrl);
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server