No matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the current page encloses the scope and start URL from the manifest.
See original GitHub issueLibrary Affected: webpack-workbox-plugin
Browser & Platform: Google Chrome
I include new GenerateSW(),
in the plugins of my webpack config but receive this warning when running lighthouse on my website
Web app manifest or service worker do not meet the installability requirements 1 reason
Service worker is the technology that enables your app to use many Progressive Web App features, such as offline, add to homescreen, and push notifications. With proper service worker and manifest implementations, browsers can proactively prompt users to add your app to their homescreen, which can lead to higher engagement
Failure reason
--
No matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the current page encloses the scope and start URL from the manifest.
Does not register a service worker that controls page and start_url
The service worker is the technology that enables your app to use many Progressive Web App features, such as offline, add to homescreen, and push notifications.
I can see that the service worker is running in my console, because it prints
LOG from GenerateSW The service worker at service-worker.js will precache 107 URLs, totaling 5.25 MB
I am also using WebpackPWAManifest
new WebpackPwaManifest({
icons: [
{
src: Icon192,
sizes: "192x192",
type: "image/png",
purpose: "any maskable",
},
{
src: Icon512,
sizes: "512x512",
type: "image/png",
},
],
name: "Example",
short_name: "Example",
orientation: "portrait",
start_url: "/",
scope: "/",
theme_color: "#ffffff",
background_color: "#ffffff",
description: "Example",
display: "standalone",
prefer_related_applications: false,
}),
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Site cannot be installed: no matching service worker detected
Place the service worker script file at the root of your website and set start_url to / , or place it wherever you...
Read more >[2022] No matching service worker detected. You may need to ...
No matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the...
Read more >How do I add a service worker to an existing app? : r/reactjs
No matching service worker detected. You may need to reload the page, or check that the scope of the service worker for the...
Read more >No matching service worker detected in PWA - IntegerByte Blog
You may need to reload the page or check that the service worker for the current page also controls the start of the...
Read more >What should I prepare for installable Web Application
No matching service worker detected. You may need to reload patge, or check that the scope of the service worker for the current...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @samgermain—apologies that all of this isn’t as spelled out as clearly as it should be in the Workbox documentation. We have a project that’s getting underway to overhaul our guides significantly.
https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle provides a good background on how the service worker lifecycle works.
When using a service worker created by
GenerateSW
, you end up with all of yourwebpack
assets precached, and served using a cache-first strategy. Browsers will continue using the cached assets associated with the service worker that’s in control of the page indefinitely, until and updated service worker moves from thewaiting
toactive
state and takes control.Reloading an open page isn’t sufficient to activate a waiting service worker; you have to close all open tabs before that happens, or alternatively, call
skipWaiting()
from within the updated service worker. This can often cause confusion as developers testing things out believe that they are permanently stuck on an old version of their precached assets.I’d recommend a few things:
First, don’t register a precaching service worker in development, as aggressively caching resources very much goes against the “hot reload” philosophy.
Second, if you want to see some approaches to programmatically triggering the
skipWaiting()
call, the “Offer a page reload for users” recipe is one approach.Third, a lot of these best practices have been baked in to the PWA template for the
create-react-app
framework already, with the code at https://github.com/cra-template/pwa/tree/master/packages/cra-template-pwa/template/src You can draw inspiration from how it avoids registering a service worker on localhost, as well as offers callbacks for triggeringskipWaiting()
programmatically.I hope that helps! If you’re still stuck, you could consider a less aggressive caching strategy than what
GenerateSW
implements by default. You can follow the guide at https://developers.google.com/web/tools/workbox/guides/get-started to write a service worker that just uses a network-first strategy if that’s more appropriate for your use case.https://developers.google.com/web/fundamentals/primers/service-workers/registration has some general guidance about when to call
navigator.serviceWorker.register('/service-worker.js');
. That would be translatable into code that would go inApp.js
in all likelihood.If you’re seeing a request for
/static/service_worker.js
then it means that something, like an older version of your site, must still be referencing your service worker from that URL (instead of from/service_worker.js
). And if you’re seeingCannot GET /service_worker.js
logged on a specific domain, that would imply that you haven’t successfully deployed the service worker to that web server at that URL.