Is at least one cache MISS guaranteed?
Given the Cache Statuses here: https://developers.cloudflare.com/cache/concepts/cache-responses/
If a resource is purged from the cache, is a worker guaranteed to see at least one
MISS
before the resource re-enters the cache?
Based on the scenarios here: https://developers.cloudflare.com/cache/concepts/revalidation/
it seems like the answer is "Yes"? Or is it possible for it to go from HIT
to UPDATING
to HIT
without ever seeing a MISS
?
Basically I'm trying to save some metadata from the origin when there was a cache miss, but I don't want to check save every outbound request, I only want to update D1 when the resource is actually different (or could be different)
My hope is that I can have something like:
Also, the site may or may not use tiered caching and cache reserve, but from the scenarios it looks like the answer should be the same regardless?2 Replies
Depending on how you purge it and your request pattern, you might see REVALIDATED or EXPIRED instead.
Each type of purge has the "Resulting cache status" documented on its page, e.g. https://developers.cloudflare.com/cache/how-to/purge-cache/purge-everything/#resulting-cache-status
A brand new never-before-seen asset will always start with a MISS though
Though in those scenarios:
-
REVALIDATED
would be that the resource hasn't changed (at least according to the origin) and thus there is no new metadata to store.
- EXPIRED
for my purposes would be the same as HIT
because the resource hasn't been updated, but on the next request for that resource, I should see a MISS
right?
Thanks for your help!
@Erisa | Support Engineer any more thoughts?