Cannot get the Cache API to cache my request

Hello,

I’ve now spent countless hours trying to get the cache API to cache a simple request. I had it working once in between but forgot to add something to the cache key, and now its not working anymore. Needless to say, cache.put() not having a return value that specifies if the request was actually cached or not does not exactly help and I am left with trial and error. Can someone maybe give me a hint on what I’m doing wrong and what is actually required? I’ve read all the documentation more than 3 times now and I’m at a loss…

Noteworthy maybe is that this REST endpoint sets pragma: no-cache and everything else cache-related to no-cache, but i want to forcibly cache the response anyway which is why I tried to completely re-write the headers before caching, but it still isn’t working (not matching or not storing, no one knows…)

async function apiTest(token, url) {
    console.log("Using cache API next attempt v16");
    let finalUrl = "https://api.mysite.com/api/"+url;
    let cache = caches.default;
    let request = new Request(
        finalUrl,
        {
            headers: {
                "Authorization": "Bearer "+token,
            },
            cf: {
                cacheEverything: true,
                cacheTtl: 900
            }
        }
    )
    // Check if the response is already in the cloudflare cache
    let response = await cache.match(request);
    if (response) {
        console.log("Serving from cache");
    }
    if (!response) {
        // if not, ask the origin if the permission is granted
        response = await fetch(request);
        // cache response in cloudflare cache
        response = new Response(response.body, {
            status: response.status,
            statusText: response.statusText,
            headers: {
                "Cache-Control": "max-age=900",
                "Content-Type": response.headers.get("Content-Type"),
            }
        });
        await cache.put(request, response.clone());
    }
    return response;
}

The cache API behaviour seems to be random at best, and definitely not well defined.
Thanks in advance

Bump, can someone please help me? I don’t often resort to asking others when I have issues and can mostly figure it out myself but this one is killing me.

Same issue.
no response from support to help fix this.