News for hackers. Stuff that matters.
Re:The myth that you can’t build interactive web apps except... by jonahx on Sunday November 17, 2024 @12:35PM (#42165501)
Can someone explain what the service worker strategy accomplishes that plain old http Cache headers don't? It saves a (almost zero weight) network roundtrip, but feels like it's re-inventing the entire wheel for that small (I think) optimization? Am I missing something?
Re:The myth that you can’t build interactive web apps except... by EionRobb on Sunday November 17, 2024 @02:01PM (#42166137)
For a multi-page app, one of the important uses of serviceworkers is pre-loading and caching resources that aren't on the first page. eg you might have a background image that's only displayed three pages deep but can download and cache it as soon as the site is open.

You can potentially use http2 push to send down files from the server early but I've seen the browser drop the files if they're unneeded for that page load.

Yes, there are other hacks you could do to make the browser download the resources early, like invisible images or preload audio files, but if you're going down that path why not put in a service worker instead and have it download in the background.

Re:The myth that you can’t build interactive web apps except... by jeroenhd on Sunday November 17, 2024 @02:54PM (#42166608)
Unfortunately HTTP/2 push is basically dead. Very few sites made use of it and Chrome removed it: https://developer.chrome.com/blog/removing-push
Re:The myth that you can’t build interactive web apps except... by xnx on Sunday November 17, 2024 @07:53PM (#42168719)
If preloading is the goal, would hidden/off-screen loading be an option for images?
Re:The myth that you can’t build interactive web apps except... by bastawhiz on Sunday November 17, 2024 @09:49PM (#42169312)
Preload link tags work great and have been supported for over a decade.
Re:The myth that you can’t build interactive web apps except... by thfuran on Sunday November 17, 2024 @01:15PM (#42165780)
A minimal network roundtrip is pretty minor only so long as you're on a reliable connection to a nearby server. Add even a little packet loss or moderate latency jitter and 5,000 miles and suddenly any roundtrip avoided is a good thing.
Re:The myth that you can’t build interactive web apps except... by slibhb on Sunday November 17, 2024 @01:26PM (#42165856)
You program servive workers in the client whereas headers are controlled by the server. Among other things, this means that service workers work when you have no internet access.
Re:The myth that you can’t build interactive web apps except... by alganet on Sunday November 17, 2024 @12:57PM (#42165649)
It was designed for apps, extensions and pages that behave like apps (stuff that might not have a server anywhere, just a manifest and some static HTML/JS). The cache is only one of the use cases.

I think some pages still use them for running background stuff. My browser is setup to clear all of them upon closing the tab.

This whole direction is being silently discontinued anyway. Running browser apps has become harder, not easier.

Re:The myth that you can’t build interactive web apps except... by imbnwa on Sunday November 17, 2024 @01:43PM (#42165984)
>This whole direction is being silently discontinued anyway. Running browser apps has become harder, not easier.

I'm outta the loop, can you expand on how this is the case?

Re:The myth that you can’t build interactive web apps except... by alganet on Sunday November 17, 2024 @02:10PM (#42166213)
When these things appeared, both Mozilla and Google were signaling the intention of distributing some kind of standard webapp. At that time, via FirefoxOS and ChromeOS. Even MS was signaling web with Windows 8 (WinJS apps, even for Windows Phone).

So, there is some piece of infrastructure for this future here and there. Service Workers is one of those pieces. But the apps only achieved some success in closed markets (extension stores). It never became a standard (visit a page, pin it, becomes a fully fledged app).

Instead, the web moved to mobile and desktop apps through other means (super-Cordoba/Electron-like apps, little JS/HTML insertions in traditional apps, other inventive web ways that do not involve a collaborative standard).

The leftovers of this imagined distribution mechanism are being pushed aside (hidden in weird menus or options). Tech is still there because it is a standard, but the counterpoint UI and market decisions are pointing in other directions.

For example, both in Chrome and Firefox, the ability to invoke the browser "chromeless" that was a part of this whole thing has been removed or muted in some way. It was never a standard, so it was removed as soon as possible (probably few people working on it).

Does that make sense?

Re:The myth that you can’t build interactive web apps except... by imbnwa on Tuesday November 19, 2024 @11:57AM (#42185571)
Ah, yes, didn't know that service workers belonged to such an larger business plan like that.
Re:The myth that you can’t build interactive web apps except... by ysofunny on Sunday November 17, 2024 @12:46PM (#42165572)
that they can be used to compute stuff locally

I imagine ideally we want user choice of where the computation is happening. if on a mobile device I'd save battery in exchange for network latency

but in a desktop computer I'd rather do as most local computation as I can

Re:The myth that you can’t build interactive web apps except... by plorkyeran on Sunday November 17, 2024 @01:39PM (#42165956)
For the sort of thing that are fast enough that network latency is relevant, on a mobile device you save battery by doing them locally. The radio takes more power than the cpu.
Re:The myth that you can’t build interactive web apps except... by jonahx on Sunday November 17, 2024 @01:10PM (#42165735)
I'm not asking about web workers generally. I'm specifically asking about their use as a client side cache as described in the article.
Re:The myth that you can’t build interactive web apps except... by bathtub365 on Sunday November 17, 2024 @12:49PM (#42165590)
Radio is one of the biggest users of battery on mobile devices.