Skip to main content

Posts

Showing posts with the label Service Worker Life Cycle

Angular Service Workers

What Is Service Workers? A Service Worker is a script which runs in the web browsers and manages to the caching for web applications. This script runs in the separates and background and doesn't need any user interactions. They can query a local cache and deliver a cached response if it is available in the cached. This makes more reliable and increases the performance. A Service Worker is a programmable network proxy and it intercept all outgoing HTTP requests and uses to allowing you to control how network requests from your page are handled. The Service Worker is a method that enables applications to take advantage of persistent data in the background processing, including hooks to enable bootstrapping of web applications while offline. What Is Service Workers in Angular? Angular 5+ start using service workers and the service workers are increased the reliability and performance of the app without needing to code against this. This is the great advantages o...

What Is Service Worker Life Cycle?

Service Worker Life Cycle -  A service worker has a life cycle that is completely separate from your web apps page. To install a service worker for our site, we need to register it, which we do in our pages. To Registering a service worker will cause the browser to start the service worker install step in the background process. Prerequisites to Supports Service workers- ü   Browser support ü   You need HTTPS How To Register A Service Worker? To install a service worker you need to kick start the process by registering it in your page. This tells the browser where your service worker JavaScript file lives. You can call below register () every time a page loads without concern; the browser will figure out if the service worker is already registered or not and handle it accordingly. if ( 'serviceWorker' in navigator ) {   window . addEventListener ( 'load' , function () {     navigator . serviceWorker . register ( '/...