Yesterday I was using Cloudflare Workers to
cache a “POST” request that sent a response with the “cache-control”: “no-cache” header. When you insert the response into Workers cache it will never be returned. The solution is to create a new Response() and manually set the “cache-control” header.
...
if (response === undefined) {
const originalResponse = await fetch(request);
response = new Response(originalResponse.body, {
headers: originalResponse.headers
});
response.headers.set("cache-control", "s-maxage=15, max-age=15");
await cache.put(cacheKey, response.clone());
}
...