3 ms·
Seems to omit the ability of a service worker to create and cache files. Not really valid as a database, which this article understandably focuses on. But it is
by beardyw 2y ago
Seems to omit the ability of a service worker to create and cache files. Not really valid as a database, which this article understandably focuses on. But it is another way to maintain files between sessions and offers the ability to access them by url as if they were on the same server. I have used it to load a zip file in the service worker and then serve the contents as if it were a file system on the server.
- evbogue 2y agoHow do you do that? I hacked this kv together with the browser's cache API: https://github.com/evbogue/bogbookv4/blob/master/lib/cachekv.js https://github.com/evbogue/bogbookv4/blob/master/lib/cachekv... which I secretly feel is not the best idea in the world but it works.
- beardyw 2y agoSorry I don't understand what that is doing. I see no reference in your code to a service worker. See https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker https://developer.mozilla.org/en-US/docs/Web/API/ServiceWork... Service worker is only present for a web page.
- evbogue 2y agoFor cachekv I was trying not to use IndexedDB because the API sucks and localStorage has space limitations that I wanted to get around so I started using the `caches` browser API to store arbitrary data. How does your example work? I'm asking because I'd like to do that instead, maybe.