Requests with a Worker enabled always "miss" on APO (behavior change)

The behavior for using Workers and APO together seems to have changed recently. It used to be the case that if you had a Worker set up for a route, any request flowing through APO that missed (and needed to hit the upstream server) would be routed through the appropriate Worker, and then the result would be cached and served to future requests to that URL. See: Will APO ever be able to run Workers on every request, instead of just origin fetches?

Now, the behavior I’m seeing is that if a Worker is enabled for a route, that route will always be a MISS in APO.

I set up a page on a test domain to show this:

This route is assigned a Worker script which does nothing:

addEventListener("fetch", async event => {
    // No-op.

Every request to this URL will miss:

❯ http --headers | grep -E 'cf-(apo-via|edge-cache)'
cf-apo-via: origin,miss
cf-edge-cache: cache,platform=wordpress

But if you hit this other post (might have to do it two times in a row as this is an unused test site) you’ll get a hit:

❯ http --headers | grep -E 'cf-(apo-via|edge-cache)'
cf-apo-via: tcache
cf-edge-cache: cache,platform=wordpress

Attn: @yevgen

Also, any progress on open-sourcing the APO Worker script implementation so I can just combine it with my own workers and stop bothering you? :smiley:

This is not a real no-op worker, try this one:

addEventListener("fetch", event => {

async function eventHandler(event) {
  const resp = await fetch(event.request)
  return resp
1 Like

On my todo list, I hope to make a good progress on it in the coming weeks.

1 Like

Ah! Thanks. Good to know.

When I do the fetch() in my handler, that does make APO work again for that route. What’s weird is that I could have sworn that two days ago my actual Workers that do stuff like HTML rewriting and header manipulation were always returning MISS… but now they’re not. Weird.