We need to speed up a API running on CF Workers Sites.
Is it possible to return a response quickly and run some slow tasks afterwards as part of the same request?
If not, what’s job queue system is recommended for CF Workers?
We need to speed up a API running on CF Workers Sites.
Is it possible to return a response quickly and run some slow tasks afterwards as part of the same request?
If not, what’s job queue system is recommended for CF Workers?
You can pass a promise to event.waitUntil(promise)
which will let the promise continue to finish after you’ve already returned a response.
I’ve uploaded a small example to worker-waituntil.js · GitHub which you can then plug into https://cloudflareworkers.com/ to see how it works.
In the example you’ll see that the promise that I passed with event.waitUntil()
still continues to run after the worker has already returned a response
Thank you, @arunesh90!