Not caching - CF-Cache-Status Header Missing in response Despite Correct Setup
Original message was deleted
Not sure if this was meant to state that if you have a worker that's using the cache API then whenever your worker is hit (cache invalidation etc) then you'll pay for invocations?If this is still confusing: Yes, Workers always run before cache. If you want to use cache with your worker, you have to use the cache api, and yes that is always a invocation

Do you mean ..responses generated by workers?You can view it that way, sure.
so do I need to have at least 2 workers, one to generate origin content, and another to do a fetch and include cf: { ttl and "cache everything } " etc?I don't think that would work, as you'd still be fetching a worker which doesn't have cache from a worker, regardless cache api is a lot simpler
that 1 extra cache.put line to includeMake sure not to miss the cache.match, gotta check if it matches anything first, if it does serve that cached response, otherwise generate and .put
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
const cache = caches.default;
let response = await cache.match(request);
if (!response)
{
const html = `<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1> ${url} ------> ${new Date().toLocaleString()}"</h1>
<p>This markup was generated by a Cloudflare Worker.</p>
</body>`;
response = new Response(html, {
headers: {
"content-type": "text/html;charset=UTF-8",
"Cache-Control": "public, max-age=300, s-maxage=600"
},
});
// ctx.waitUntil lets us return a response (without making the user wait for cache) but not end the worker invocation without first caching the response
ctx.waitUntil(cache.put(request, response.clone()));
}
return response;
}
};