with a worker in the middle, you gotta handle frontend <-> worker <-> supa errors
with a worker in the middle, you gotta handle frontend <-> worker <-> supa errors
cf: {
cacheTtl: 3600,
cacheEverything: true,
}, in my fetch request.
So i am expecting for the same request with in my window of an hr, the 2nd fetch response would be taken from the cache not go to make another http request correct ?Cache by default is per colo/cf dc, and some Cloudflare Points of Presence even have multiple colos, so you might be routed to a different one/different visitors will certainly be, and get MISS's, plus TTL is just a max and CF may evict it far before then based on access frequency.
if this is the case why for every fetch request i do the worker gets called and returns the response?The worker will always be invocation/run on every request, even if using cache
How can i validate that this is from the cache or not?Check response headers for CF-Cache-Status


npm run dev and worker A is bound to worker B. Worker B calls Worker A, and when I start Worker B I get:Cannot read properties of undefined (reading 'fetch') cf: {
cacheTtl: 3600,
cacheEverything: true,
},⛅️ wrangler 3.41.0
-------------------
▲ [WARNING] This worker is bound to live services: AUTH (authentication-worker)
Your worker has access to the following bindings:
- Services:
- AUTH: authentication-worker
▲ [WARNING] ⎔ Support for service bindings in local mode is experimental and may change.Cannot read properties of undefined (reading 'fetch')#[event(fetch)]
async fn fetch(req: HttpRequest, _env: Env, _ctx: Context) -> Result<Response<Body>> {
console_error_panic_hook::set_once();
let cors = CorsLayer::new()
.allow_origin("https://shorter.dev".parse::<HeaderValue>().unwrap())
.allow_headers([CONTENT_TYPE])
.allow_methods([Method::GET, Method::POST, Method::HEAD, Method::OPTIONS]);
let app = Router::new()
.route("/", get(|| async { "shorter.dev server!" }))
.merge(mount())
.layer(cors)
.call(req)
.await?;
Ok(app)
}