Cole-kun
Cole-kun
CDCloudflare Developers
Created by Razzmatazz on 3/18/2024 in #workers-help
Caching POST requests works but shows warning in console
That's... interesting. I'm facing the same issue, now. šŸ¤”
let newResponse = new Response(response.clone(), response.headers );
context.waitUntil(cache.put(cacheKey, newResponse));

console.log(`newResponse Body Used: ${newResponse.bodyUsed}`)
return response;
let newResponse = new Response(response.clone(), response.headers );
context.waitUntil(cache.put(cacheKey, newResponse));

console.log(`newResponse Body Used: ${newResponse.bodyUsed}`)
return response;
---- [wrangler:inf] GET / 200 OK (1249ms) newResponse Body Used: true A ReadableStream branch was created but never consumed. Such branches can be created, for instance, by calling the tee() method on a ReadableStream, or by calling the clone() method on a Request or Response object. If a branch is created but never consumed, it can force the runtime to buffer the entire body of the stream in memory, which may cause the Worker to exceed its memory limit and be terminated. To avoid this, ensure that all branches created are consumed. šŸ˜•
6 replies
CDCloudflare Developers
Created by Rich on 5/9/2024 in #kv
Yikes, that's really disappointing.
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "728",
"localCache": false,
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "598",
"localCache": true,
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "97",
"localCache": true,
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "728",
"localCache": false,
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "598",
"localCache": true,
coleplx@argus:~/cloudflare$ curl -sILX GET https://redacted/building-exterior.webp?1bypass2 -H 'x-debug: redacted' | grep -Ei '^x-debug' | cut -d':' -f2- | jq | grep -E 'localCache|ColoId'
"cfColoId": "97",
"localCache": true,
Yep. This Worker route is using Cache API only. I wish they documented or at least announced these changes somewhere, at least here on Discord. šŸ˜… That's valuable information.
52 replies
CDCloudflare Developers
Created by Rich on 5/9/2024 in #kv
Yikes, that's really disappointing.
Yes, it was MCP-related. Thank you! I've been trying to remember that name. šŸ˜… It seems Cache API now shares its storage between all DCs in a region. Not as good as Tiered Cache, but definitely much better than before.
52 replies
CDCloudflare Developers
Created by Rich on 5/9/2024 in #kv
Yikes, that's really disappointing.
Is this still valid? I had a talk with a CF eng recently, and it seems they changed this behavior last month. I tested it with a few colos today and got a HIT immediately after the first MISS, all from different Colo IDs.
52 replies
CDCloudflare Developers
Created by Apoc on 11/9/2023 in #workers-help
Workers fetch cache (tiered caching) - How to handle conditional caching?
AFAIK, you will need to use both Workers and your origin to use fetch cache correctly. caches.default.delete is a Cache API operation, and it is local to where the Worker ran. It won't work with Tiered Cache/Fetch Cache. One way to do it:
cf: {
cacheEverything: true,
cacheKey: cacheKey,
cacheTags: do-your-stuff-etc
}
cf: {
cacheEverything: true,
cacheKey: cacheKey,
cacheTags: do-your-stuff-etc
}
And then make your Origin send the necessary headers to make this work, for example, Cloudflare-CDN-Cache-Control. Fetch should respect it, not caching private content, etc.
2 replies
CDCloudflare Developers
Created by Chakri on 8/15/2023 in #workers-help
Change POST request to GET request using workers for the same url.
I guess so... The documentation has this example showing how to cache POST requests: https://developers.cloudflare.com/workers/examples/cache-post-request Part of it shows how to convert POST to GET
3 replies