I’m trying to write a CF worker that caches files from a B2 bucket so that users don’t have to send all traffic to B2 every time to get the same file over and over. ( I know the BW is free already, but seems excessive and worse for the user ).
In my worker I’m running:
let request = event.request let cache = caches.default let response = await cache.match(request)
and response is always empty. After catching this, and running fetch to get the request I’m then seeing a header with
cf-cache-status: HIT which means that the request is in the cache - so why is it missing the original cache ?
Here is the code I’m using -
The headers I’m adding,
n-cache is always ‘miss’, but after the second request
cf-cache-status: HIT is returned. Is there something I’m doing wrong? I’m using a Pro plan, so I don’t have Enterprise features, but from the documentation it implied that cache.put was still available on responses.