I am sorry if this has been asked before is a very obvious question, but I am currently thinking about using workers and wanted to know if my scenario could work before actually starting to develop.
I have seen many examples where resources are fetched from a foreign server, and after the resources have been fetched, a result is returned (e.g., this example). Now I am wondering how the CPU time is calculated, is the “timer stopped” when fetching a resource (e.g.,
fetch('https://api.coinbase.com/v2/prices/BTC-USD/spot', init)) or is the timer started when calling the worker and stopped once the worker is done?
This would mean that fetching foreign resources is not possible on the free or pro plan, and only very limited on the business plan? But then, fetching network resources is not really “CPU” time.
A brief overview what I wanted to do:
- Fetch a medium size resource (<1mb), (e.g., example.com/1.png)
- If the request results in a 200, this would be returned.
- If the request results in a 404, the worker would request a fallback (e.g., fallback.com/1.png) and return this.
As far as I understand workers, this would be a good use case for workers?