Worker Cache API doesn't cache requests anymore

caching
#1

Hi.

I’m caching all the requests that pass through the worker like this

    const cache = caches.default
    response = await cache.match(request)
    if (!response) {
        response = await fetch(request)
        event.waitUntil(cache.put(request, response.clone()))
    }

I have some tests that look for the cf-cache-status header after making the same request twice. The header used to appear but now it doesn’t anymore.

0 Likes

#2

Fetch needed the cacheEverything option

fetch(request, { cf: { cacheEverything: true } })
0 Likes