3 ms·
> They don't work offline This isn't true. Offline functionality is the raison d'être for Service Workers. You can run an entire HTTP request router on the cli
by throwitaway1123 2y ago
> They don't work offline
This isn't true. Offline functionality is the raison d'être for Service Workers. You can run an entire HTTP request router on the client to respond to requests while offline: https://hono.dev/docs/getting-started/service-worker https://hono.dev/docs/getting-started/service-worker
- Spivak 2y agoAre you guys okay? Don't get me wrong it's clever, but it's also insane. If I pitched the idea of having SMB shares work online by shipping a driver that could intercept low level SMB calls and reroute them to a mock SMB server that holds the cache they would have assumed I'd lost it. Surely the browser could help you a bit more to implement offline sites in a more integrated fashion.
- throwitaway1123 2y agoIt's ultimately just a little event listener function that accepts a Request object and returns a Response object. I bundled the service worker by running a quick `npx esbuild --minify --bundle --outfile=sw.js sw.ts` command, and it produced an 18.6kb JS file in 10 milliseconds. That's not even half the size of libraries like HTMX, Alpine, and jQuery. You can of course use the CacheStorage API directly as well (you're not obligated to use a mock server): https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage#examples https://developer.mozilla.org/en-US/docs/Web/API/CacheStorag... I've certainly seen crazier things though. People routinely include entire copies of Ubuntu LTS in their Docker images to ship tiny HTTP servers.