How to return fallback content from Workers?
I have a single file (an image) that I'd like to return from a Worker, but I don't want the image to depend on the Worker. So, if the worker was to fail to run (from hitting a rate limit or otherwise) the file would still be returned.
I've been thinking the best way to do this is to host the file on Pages, and use Functions to execute a Worker as a side-effect every time the Pages site receives a request, but I'm not sure how to do that. Is this possible and if so how would I do it? (or is there a better way?)
1 Reply
If the image is hosted on an origin then you can use https://developers.cloudflare.com/workers/runtime-apis/context/#passthroughonexception to skip the Worker if it errors