

fetch() with cf.image option then push it to Cache API. This implementation has a problem when Cache API is a data-center-bounded and presigned url changed every time I sign it, so I cannot take the advantages if image delivery cache. Users from multiple regions who request the same resource will make image transform transforms more than one time. Especially when crawlers and bots trying to scrape my page , they make a huge hit to my wallet (4-5k images daily, approx 60k for 2 weeks). I'm trying to mitigate it by returning the original image if the request comes from well known bots or does not has Referer value be my page, but it does not solve the Cache problem above. Is there any elegant solution for this? Thank you.node:http function for a workerwww-staging.foo.com that is controlled by Cloudflare, and we're using a CNAME to staging.actual-origin.com let's say, and it is WordPress but not sure that matters but naturally it's expecting requests from www-staging.foo.com in terms of the host./the-page-to-intercept with a Worker, call await fetch(request) to hit the origin, and then modify the response before returning it from the worker (creating a new response really).staging.actual-origin.com) is returning an error that suggests the host isn't being sent through - if I hit the downstream URL in the browser I get the same error (the error is site not found, effectively). Is this just some quirk of CNAMEs where it's not correctly hitting the origin, and is there any way to fix this / am I doing something dumb? I thought about setting the host header but that's not allowed with the Fetch API pretty surewww.foo.com from www-staging.foo.com inside the worker) but there must be some quirk I'm missing herewww-staging.foo.com, which by default will proxy using a CNAME to staging.actual-origin.com www-staging.foo.com as the URL. I've tried both fetch('www-staging.foo.com') and fetch(request) to no avail - both give the same result, assuming there's no caching funny-business going on.staging.actual-origin.com) requires a specific HTTP header to be set - this is done by a transform rule when proxied - but naturally as the worker intercepts that transform rule isn't applied. So in theory I just need to set that, then it should workconst newRequestInit = {
headers: {
'X-custom-header': 'some-val',
}
}
const newRequest = new Request(
request,
new Request(request, newRequestInit)
);
return await fetch(newRequest)