Bypass Cache Worker

Is there a snippet someone can share that would show me a simple worker that you can add paths to, a general worker to invalidate cache or set a custom level?

I want to bypass cache on some uris and don’t want 100 page rules to do it. I see how I can set a response – but I’m looking for a way to set the cache level from a worker.

This simple script below just 404’s a page (not what I am asking for in this post). I am looking for something along these lines though. I don’t see an example in the snippets to show how to set the cache level. Anyone got a pro-tip for me?

addEventListener(‘fetch’, event => {

async function handleRequest(request) {
return new Response(‘Not Available’, {status: 404})

1 Like

The following worker recipe may be a start. If you need further help adapting the recipe to your actual needs, I’d suggest you edit your original post to change the category from Getting Started to Developers > Workers.


That’s just the start I needed. Not sure how I missed that in my search. Thanks!

1 Like

This topic was automatically closed after 31 days. New replies are no longer allowed.