Live data from Hacker News

Service Workers

frontendian.co

31–40 of 68 posts

Re: Service Workers

#31

Earlier quoted context omitted.

The service worker does not maintain a persistent connection. Some websites/pwa's allow you to configure that.

but then you're depending on the website/pwa to be a good citizen and allow you to configure that

That's ok, I'm sure the EU will sort out some kind of service worker popup in due course!

Re: Service Workers

#32
post #28

Earlier quoted context omitted.

My most delightful experience with a service worker was SVGOMG, https://jakearchibald.github.io/svgomg/ . One time I was without an internet connection, and I thought to myself, “if only it had a service worker so it’d work offline!” and then I opened a tab to it, to remind myself to optimise the SVG I was working with later, and— huh. It loaded. On reflection, I decided that given who Jake Archibald is, it made sens…

I've recently set an offline mail client to sync mail locally for my wife's laptop. Her two gmail accounts downloaded 22GB. Be careful what offline actually means when it comes to mail; eg. that 22GB as service worker cache sounds a bit nasty to me, especially because service workers don't tend to differentiate between desktop and mobile.

Definitely. I’d hate to have it download all my mail on my laptop or my phone. We have yet to particularly consider the UI for controlling it, but I fully expect that anything in the way of synchronisation rather than simple caching of what we’re already fetching (and only limited amounts of that—there’s already an LRU GC on the cache) will require manual configuration, probably with options like “sync the inbox” or “sync the last 30 days of mail”, and probably projections of probable storage requirements.

Re: Service Workers

#33

Earlier quoted context omitted.

Push requests only exists on Chrome and is behind a permission, intercepting resource requests within the domain of a website could cause some annoyances, can’t see the malware effect immediately. Scheduling a download for a stable connection, again, could be an annoyance, but what’s the malware implication?

The malware angle is basically service-worker-powered cache poisoning: if you can get the server to serve your code once, users can get a service worker installed, and intercept resource requests under that path. It’s limited in practical value because you have to be able to serve a full JS file as the service worker, rather than just injecting a snippet of JS as the most common technique is, but it is a genuine atta…

Service workers automatically reload after 24 hours, regardless of caching headers (though I believe they’ll respect a 304). I believe this was done partially to limit the duration of such a compromise.

Re: Service Workers

#35

"Imagine being able to respond to push notifications, intercept resource requests, and schedule background syncronization, all without the need for a user to actively have your website open in front of them." ".. by authoring special-purpose JavaScript which you register with the browser." Why does this seem like something useful for malware and generally annoying me.

Most new web features seem to enable malware and other scummy thing all to promote the web as an app platform.

I would we rather leave http to be a document model, and create something new and better to support"web-based" apps.

Re: Service Workers

#36
post #5

I like service workers, but I don't like the lack of control I have. For example, I want Messenger to send me notifications if I have the tab open, but I don't want the service worker to maintain a persistent connection and send me notifications with the tab closed. Unfortunately, I am not able to block service workers. My only option is to block notifications entirely, which doesn't even stop the service worker.

The service worker does not maintain a persistent connection. Some websites/pwa's allow you to configure that.

The service worker should not be allowed to listen to global-push notifications without me telling it to.

The notifications dropdown should be:

- Always allow

- Allow when open

- Disallow

Re: Service Workers

#37
post #8
post #3

Great write up. I’ve been exploring SWs recently to help with downloading and caching data in the background for faster UI. Question, I’d like to avoid doing large downloads or possibly cap the transfer rate to avoid any potential jank. Is there a best practice or is it possible to monitor the current browser interaction to determine how strategically best to pull data with a SW? Depending on what a user chooses to c…

May I ask the justification to download 1-10MB JSON on the user's system without the user being aware?

They are aware, it’s business software, syncing records/templates/frequent info etc. It’s only to improve the experience, and it’s controlled by settings/opt-in etc.

It’s also configurable to only operate on faster connections/non mobile IP address etc.

The main reason I was asking is if you currently benchmark service worker updates with indexedDB for async/larger updates, they still cause a small amount of jank, (at least on larger requests) even though they may use a different process etc.

There’s a github repo with a benchmark, this link is older but if you clone the current version and update to the lastest packages, the results are still similar.

  https://www.google.com/amp/s/nolanlawson.com/2015/09/29/indexeddb-websql-localstorage-what-blocks-the-dom/amp/

Re: Service Workers

#40
post #20

Earlier quoted context omitted.

You also cache regular web resources like images. It is for the user's benefit since next visit to the site can be faster.

You misunderstand. Service worker traffic is invisible, unlike loading an image and generally speaking can't be governed, unlike visible elements. Loading 1-10MB JSON might drain a significant portion of mobile data. It could take a long time, meaning it may need to re-start it a couple of times, due to, say, a flaky 3G connection. I'm curious on the why - unless this is an announced feature, I don't think this shoul…

I agree with you, there are several settings avail to control what is optimized, it’s typically enabled on faster devices/connections at work. I would be upset as well if a site naively used up a connection in the background.
Post reply on HN