3

In the context of Progressive Web Apps (PWA) there are two terms that I am trying to better understand:

What is the difference between them and their intended use? Are they similar in any ways? Or may be they are in some relation?


In my current understanding, a Service Worker is truly the foundation of a PWA; i.e. the object which enables a web app as a "registrable" app for mobile platform, allows offline functionality, and so on.

Whereas a Web Worker is an entity which allows [JavaScript] code execution in a background, non-UI thread with all the ensuing consequences (such as no direct DOM manipulation).

1
  • Dear down voter, care to explain what is wrong with my question or it's the Software Engineering's notorious unfriendliness? Commented Sep 6, 2018 at 21:55

1 Answer 1

2

NOTE: I read the links you gave and tried to figure out. I have no other experience with the subject. From the docs, both kinds of workers look like daemon processes listening to events coming from the "main process" of a page. Both have no access to DOM and communicate with the "main process" using pipes or futures which are conceptually similar.

A Web Worker waits on a queue and processes (arbitrary) messages as it receives them. It can do arbitrary computation or I/O, within the page's security confines.

A Service worker waits on a URL-like resource, and processes access to it as it is requested. It can do things like routing, prefetching, caching, or substituting a remote resource for a local copy when offline. The example by the link you gave explains this in detail.

Probably the latter can be, and is, implemented in the terms of the former.

1
  • Thanks for helping getting confidence in understanding. Probably the latter can be, and is, implemented in the terms of the former. -- I agree, one is achievable by means of the other, but I don't know if it is actually the case (which is curious of course). Commented Sep 7, 2018 at 19:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.