Open adamziel opened 1 year ago
A recent article describes how Notion used SharedWorker
to share an SQLite database in OPFS across multiple browser tabs.
To execute any SQLite query, the main thread of each tab sends that query to the SharedWorker, which redirects to the active tab’s dedicated Worker. Any number of tabs can make simultaneous SQLite queries as many times as they want, and it will always be routed to the single active tab.
How we sped up Notion in the browser with WASM SQLite
The idea was earlier explored in detail in wa-sqlite
.
It's basically how you imagined in this comment.
Another option would be to use
SharedWorker
as a traffic controller that elects one of the active tabs as a "leader" and uses it to resolve all the requests.
Browsing the same WordPress instance in multiple browser tabs could be useful. Props to @gziolo for the idea.
Technically, it would take: