It have benfits like zero cold startup, it automatically stop the worker when it’s not needed. and it could have the potential for also scaling up more workers when it’s busting the as of by lot of heavy work.
Not only dose it also comes with lots of cool features like a scoped browser storages for different purposes. it also has caching, push notification and now a whatwg/fs for handling files as well. it also feels more secure in a way, that no way could it have access to any secret directories
I also like it cuz it’s well battle tested and also follows a standard specifications and comes with fetch natively built in, you can with some flags turn off some security issues when dealing with cross site requests.
Another potential useful feature could be to use Clients to open up a page and reder stuff on a webpage or canvases and then use transferable Streams to write and RespondWith some data. if you depend on some web DOM api’s
the direct socket proposal is also a cool feature, but i’m unsure if it could fit the need to be acting as a server.
if we could make it somewhat easier for browser to take over the role as a server then that would be pretty cool!
I’m not really expecting anything like this to be directly available without a flag of some sort.
I’m imagine being able to run some Node/Deno-like commands but with browsers instead, something like:
/path/google\ chrome.app install-worker ./sw.js --origin=localhost:3000
or maybe there could be some sort of api to install a service worker on a randomly assigned port using something from the direct socket api that spins up a new server