From 60a2a83a791868957c4fe4108b5310e2caba165f Mon Sep 17 00:00:00 2001 From: Judy Bogart Date: Wed, 7 Aug 2019 11:13:24 -0700 Subject: [PATCH 1/2] docs: doc browser support for service workers --- aio/content/guide/service-worker-intro.md | 34 +++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/aio/content/guide/service-worker-intro.md b/aio/content/guide/service-worker-intro.md index e9678ca1ff52e..a537247fe5143 100644 --- a/aio/content/guide/service-worker-intro.md +++ b/aio/content/guide/service-worker-intro.md @@ -31,11 +31,34 @@ Installing the Angular service worker is as simple as including an `NgModule`. I ## Prerequisites -Your application must run in a web browser that supports service workers. Currently, service workers are supported in the latest versions of Chrome, Firefox, Edge, Safari, Opera, UC Browser (Android version) and Samsung Internet. Browsers like IE and Opera Mini do not provide the support. To learn more about other browsers that are service worker ready, see the [Can I Use](https://caniuse.com/#feat=serviceworkers) page and [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). +To make use of all the features of Angular service worker, use the latest versions of Angular and the Angular CLI. -In addition, in order for service workers to be registered, the app must be accessed over HTTPS, not HTTP. Browsers will ignore service workers on pages that are served over an insecure connection. The reason is that service workers are quite powerful, so extra care needs to be taken to ensure the service worker script has not been tampered with. +In order for service workers to be registered, the app must be accessed over HTTPS, not HTTP. +Browsers ignore service workers on pages that are served over an insecure connection. +The reason is that service workers are quite powerful, so extra care needs to be taken to ensure the service worker script has not been tampered with. + +There is one exception to this rule: to make local development easier, browsers do _not_ require a secure connection when accessing an app on `localhost`. + +### Browser support + +To benefit from the Angular service worker, your app must run in a web browser that supports service workers in general. +Currently, service workers are supported in the latest versions of Chrome, Firefox, Edge, Safari, Opera, UC Browser (Android version) and Samsung Internet. +Browsers like IE and Opera Mini do not support service workers. + +If the user is accessing your app via a browser that does not support service workers, the service worker is not registered and related behavior such as offline cache management and push notifications does not happen. +More specifically: + +* The browser does not download the service worker script and `ngsw.json` manifest file. +* Active attempts to interact with the service worker, such as calling `SwUpdate.checkForUpdate()`, return rejected promises. +* The observable events of related services, such as `SwUpdate.available`, are not triggered. + +It is highly recommended that you ensure that your app works even without service worker support in the browser. +Although an unsupported browser ignores service worker caching, it will still report errors if the app attempts to interact with the service worker. +For example, calling `SwUpdate#checkForUpdate()` will return rejected promises. +To avoid such an error, you can check whether the Angular service worker is enabled using `SwUpdate#isEnabled()`. + +To learn more about other browsers that are service worker ready, see the [Can I Use](https://caniuse.com/#feat=serviceworkers) page and [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). -There is one exception to this rule: To make local development easier, browsers do _not_ require a secure connection when accessing an app on `localhost`. ## Related resources @@ -46,7 +69,6 @@ For more information about browser support, see the [browser support](https://de The remainder of this Angular documentation specifically addresses the Angular implementation of service workers. -## More on Angular service workers +## Next steps -You may also be interested in the following: -* [Getting Started with service workers](guide/service-worker-getting-started). +To begin using Angular service workers, see [Getting Started with service workers](guide/service-worker-getting-started). From fd525587af78344c5d7bbefc2c4a287c1b45e394 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 14 Aug 2019 14:50:42 +0300 Subject: [PATCH 2/2] fixup! docs: doc browser support for service workers --- aio/content/guide/service-worker-intro.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aio/content/guide/service-worker-intro.md b/aio/content/guide/service-worker-intro.md index a537247fe5143..297bd92091c5b 100644 --- a/aio/content/guide/service-worker-intro.md +++ b/aio/content/guide/service-worker-intro.md @@ -54,8 +54,8 @@ More specifically: It is highly recommended that you ensure that your app works even without service worker support in the browser. Although an unsupported browser ignores service worker caching, it will still report errors if the app attempts to interact with the service worker. -For example, calling `SwUpdate#checkForUpdate()` will return rejected promises. -To avoid such an error, you can check whether the Angular service worker is enabled using `SwUpdate#isEnabled()`. +For example, calling `SwUpdate.checkForUpdate()` will return rejected promises. +To avoid such an error, you can check whether the Angular service worker is enabled using `SwUpdate.isEnabled()`. To learn more about other browsers that are service worker ready, see the [Can I Use](https://caniuse.com/#feat=serviceworkers) page and [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API).