cloudflare / templates

A collection of starter templates and examples for Cloudflare Workers and Pages
https://cloudflareworkers.com
MIT License
999 stars 632 forks source link

Unable to bypass at all. Documentation missing page rules. #53

Closed markomitranic closed 3 years ago

markomitranic commented 4 years ago

Hey everyone,

So, i've deployed the edge-cache worker successfully, but once i started debugging everything i figured out that it pretty much does nothing.

For example, if i change the following line:

function shouldBypassEdgeCache(request, response) {
  console.log('iamhere');
  return true;

I am able to confirm through the debugger that the line triggers, but my cf-cache-status is still HIT. Actually i have tried much more aggressive stuff in the worker, and i am not seeing any misses (after the first one obviously). Which leads me to believe that the actual Hits are not tied to the worker at all. Instead they are hits from the regular CF cache-everything page rule. It is my belief that the subsequent await fetch() actually just hits the CF cache catch-all all over again, and never pulls from the origin anyways.

How come?

Screenshot 2020-03-12 at 12 20 14

If that is the case, does it mean that i have misinterpreted the purpose of the worker? (to decide which requests will not be handled by cache), or does it mean that i have set my page rules in a wrong way? In which case, we should add the recommended page rules to the docs, ASAP.

Has anyone got this working correctly?