Since Cloudflare doesn’t support stale-while-revalidate, we are trying to make this work using the Cache API + Worker.
What we are trying to do is something like this:
- First access:
If cache status != HIT -> Deliver Stale -> Fetch the origin server in Background -> Save New Cache.
- Second Access:
Deliver Cached content until expired and then repeat the process.
My question is: how do i make a worker deliver the STALE content? I couldn’t find that option in Cache API docs.
Also, has anyone done this with a worker before?
Ps: Please Cloudflare, make SWR work the way it should!