3 ms·
This SO answer seems to say that it wouldn't work : https://stackoverflow.com/questions/61041389/managing-server-side-events-with-a-service-worker https://stack
by cassepipe 3y ago
This SO answer seems to say that it wouldn't work : https://stackoverflow.com/questions/61041389/managing-server-side-events-with-a-service-worker https://stackoverflow.com/questions/61041389/managing-server...
If you have an answer to that answer I'd be very much interested
- jraph 3y agoYou can use BroadcastChannel [1] to communicate between tabs. It works well and does not require service workers. It's used in Tracim [2], for some reason we could not move to HTTP/2 at the time I was working on this project so we indeed learned about this connection limit soon enough… Even on HTTP/2, I believe it's best avoid sending 6 times the same message to the user just because they opened 6 tabs. It's less wasteful both for the server and the client. [1] https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel https://developer.mozilla.org/en-US/docs/Web/API/BroadcastCh... [2] https://github.com/tracim/tracim/blob/develop/frontend_lib/src/LiveMessageManager.js https://github.com/tracim/tracim/blob/develop/frontend_lib/s...
- cassepipe 3y agoThanks very much for the examples ! I get your point but it does seem quite more involved to do all that management and broadcasting by hand rather than having a shared worker with a EventSource singleton for all, don't you think ? : https://stackoverflow.com/a/61636606/10469162 https://stackoverflow.com/a/61636606/10469162 EDIT: Someone posted this very relevant and interesting post : https://greenvitriol.com/posts/browser-leader https://greenvitriol.com/posts/browser-leader