Example of using Cloudflare Workers to cache 301 responses

@sdayman I saw where you mentioned “I use a Worker for my site caching, and it’s similar to how APO works, but it caches my 301 request” here Caching 301s from origin - #4 by user17876

That sounds like a great idea, as I currently have the same issue in the link where I get: cf-apo-via origin,resnok: Page is served from origin, origin returned non 200 status, we cache requests with 200 status only.

Would you be able to share a link or sample code or the like of how you have a Worker set up so that 301s get redirected at the cloudflare edge and don’t go back to the origin?

Thank you

Hi there,

We have a dedicated section for Workers Examples here:

Not entirely sure but I think this might be the example that you are looking for:

if you have any other questions, I highly suggest you checking our Discord channel, where you will find a lot of talented programmers that will be glad to help you with your Worker.