dumberjs / dumber-gist

A lightweight online IDE to write JS SPA prototypes in your own GitHub gists.
https://gist.dumber.app
MIT License
28 stars 2 forks source link

TODO: cleanup routine for used random-id embedded user app #17

Closed 3cp closed 4 years ago

3cp commented 4 years ago

dumber-gist uses host name random-id.gist.dumber.app on the embedded user app to isolate multiple dumber-gist app, so the service worker on the embedded user app would not cross-talk.

But browser will keep those installed service workers even they will never be used again.

Possible cleanup routine.

  1. every dumber-gist instance register an entry in localStorage or indexedDB after the random-id.
  2. keep update the same entry periodically, this is a heart beat.
  3. dumber-gist should cleanup service-worker on those dead entries.
    • temporarily open an invisible iframe with outdated random-id, call service worker unregist, close the iframe.

The problem: localStorage and indexedDB can be cleared by user or the browser itself, maybe not using random-id, but an increasing seed?

3cp commented 4 years ago

Maybe can use a service worker on host gist.dumber.app, not for offline cache, but to collect random-id info from all opened dumber-gist instances. So that the saved random-ids live in service worker instead of storage.

3cp commented 4 years ago

Note: Not a perfect solution, if user close last dumber-gist window, reset browser localStorage, then open a new dumber-gist window, the last used service worker would not be cleared.

3cp commented 4 years ago

It looks like the iframed dumber-gist on Safari uses sandboxed localStorage. The result is user has to revisit the same page contains the iframed dumber-gist to clean up previously used service worker.

3cp commented 4 years ago

I don't know what else could be done for Safari implicit sandbox. Close it for now.