Registering a service worker is the first step towards enabling the following progressive web app features:
- Push notifications
- Add to homescreen
Learn more in Service workers and the Cache Storage API. Lighthouse flags pages that don't register a service worker:
How this audit fails
Lighthouse checks if the Chrome Debugger returns a service worker version. If it does not, the audit fails.
Each PWA audit is weighted equally in the Lighthouse PWA Score, with the exception of three manual audits: Site works cross-browser, Page transitions don't feel like they block on the network, Each page has a URL. Learn more in The Progressive Web App score.
Registering a service worker involves only a few lines of code, but the only reason you'd use a service worker is to implement one of the progressive web app features outlined above. Implementing those features requires more work. For more help on caching files for offline use, see What is network reliability and how do you measure it?.
For enabling push notifications or "add to homescreen", complete the following step-by-step tutorials and then use what you learn to implement the features in your own app:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.