Questions tagged [service-worker]

A service worker is JavaScript code that, once registered with an associated origin and scope, will respond to browser-initiated events, even when the pages it controls are no longer open. By handling `fetch` events, service workers can provide custom network behavior, like offline support (via the Cache API). By handling `push` events, service workers can be "woken up" and display notifications.


4030 questions
183
votes
15 answers

How do I uninstall a Service Worker?

After deleting /serviceworker.js from my root directory, Chrome still runs the service worker that I removed from my webroot. How do I uninstall the service worker from my website and Chrome so I can log back into my website? I've tracked the issue…
Mark Tomlin
  • 7,684
  • 8
  • 51
  • 68
145
votes
3 answers

What can service workers do that web workers cannot?

What can service workers do that web workers cannot? Or vice versa? It seems that web workers are a subset of the functionality of service workers. Is this correct?
Ben Aston
  • 45,997
  • 54
  • 176
  • 303
116
votes
9 answers

Options for testing service workers via HTTP

I want to test service workers but I have a virtual host setup and I can't seem to be able to enable https on localhost. How can I whitelist my local virtual host url to test service workers whenever I try and register for the service worker on the…
100
votes
3 answers

What is service worker in react js

When creating a react app, service worker is invoked by default. Why service worker is used? What is the reason for default invoking?
usergs
  • 1,084
  • 3
  • 6
  • 16
95
votes
1 answer

What limitations apply to opaque responses?

Opaque responses are defined as part of the Fetch API, and represent the result of a request made to a remote origin when CORS is not enabled. What practical limitations and "gotchas" exist around how opaque responses can be used, both from…
Jeff Posnick
  • 45,379
  • 12
  • 113
  • 142
87
votes
1 answer

Angular Service Worker - Failed to load resource: the server responded with a status of 504 (Gateway Timeout)

I am using the Angular-CLI 1.6.6 and @angular/service-worker 5.2.5 in our Angular 5.2.5 app. Everything works fine on the local lite-server, as well as on the production server, except for one error message popping in our production environment:…
80
votes
8 answers

Can you use a service worker with a self-signed certificate?

I have developer server that are used for testing. They have SSL self-signed certificates, which allow us to test the web application over HTTPS, but with prominent warnings that the certificates are not verifiable. That's fine, but I have a Service…
Keith
  • 133,927
  • 68
  • 273
  • 391
77
votes
5 answers

What is the storage limit for a service worker?

Most of the browsers provide localStorage with the storage limit of 5MB per domain. Are there such memory limits/constraints with respect to service workers? I know that web workers (on which service workers are based) don't have such limitations.…
Nachiketha
  • 12,055
  • 2
  • 22
  • 30
75
votes
2 answers

What does registerServiceWorker do in React JS?

I'm a newbie in React and I was wondering what is the purpose of registerServiceWorker() in the following code? import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import registerServiceWorker from…
user7232873
75
votes
7 answers

How can I remove a buggy service worker, or implement a "kill switch"?

I'm playing with the service worker API in my computer so I can grasp how can I benefit from it in my real world apps. I came across a weird situation where I registered a service worker which intercepts fetch event so it can check its cache for…
PaquitoSoft
  • 2,937
  • 3
  • 26
  • 32
72
votes
2 answers

Service worker JavaScript update frequency (every 24 hours?)

As per this doc on MDN: After that it is downloaded every 24 hours or so. It may be downloaded more frequently, but it must be downloaded every 24h to prevent bad scripts from being annoying for too long. Is the same true for Firefox and…
68
votes
2 answers

When and how does a PWA update itself?

As far as I know, once you click "add to homescreen" on a PWA's website, the browser generates an .apk using the provided manifest file and sources and installs it like a normal app. I noticed that when I update the website, the app also displays…
57
votes
3 answers

Why use a service worker for caching when browser cache handles the caching?

I read that using a service worker for offline caching is similar to browser caching. If so, then why would you prefer a service worker for this caching? Browser caching will check if the file is modified or not and then serve from the cache, and…
bvakiti
  • 2,263
  • 1
  • 13
  • 24
57
votes
5 answers

navigator.serviceWorker is never ready

I registered a service worker successfully, but then the code navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { // Do we already have a push message subscription? .... hangs -- the function is never called. Why?
Larry K
  • 42,977
  • 12
  • 82
  • 121
56
votes
5 answers

Can't find serviceWorker in navigator anymore

since the new update of Google Chrome (version 69.0.3497.92 (official build) (64-bit)) I can't find the serviceWorker service in the Navigator anymore. Actually I could register my Service Worker as follows but now I get an error that serviceWorker…
Dieter Information
  • 775
  • 1
  • 6
  • 11
1
2 3
99 100