I discovered Cloudflare workers, looking for a way to redirect my users depending on their country, if they don’t have a pre-existing cookie. I previously did this directly from my PHP script.
This means that a french user going to
- Load the page.
- Get redirected to
- Load again
I thought workers would prevent the first load, and redirect instantly to
fr.mywebsite.com without going to my server.
What I’m having a hard time understanding from this example is why do we have to fetch the page anyway? Is
fetch actually loading the page, or just looking if it returns a 200 status code?
On a side note, I think there’s an error on Random Content Cookies example: it should probably return