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 don'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 increase the performance.
A Service Worker is a programmable network proxy and it intercept all outgoing HTTP requests and use 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.
Angular 5+ start using service workers and the service workers are increased the apps reliability and performance without needing to code against this.
This is the great advantages for angular and Angular’s service worker is designed for -
ü Improve the performance regarding the unreliable network connection
ü Minimizing the risks of serving outdated content
ü It’s Optimize the end user experience
The main Design Goal of Angular's Service Worker -
ü Caching an application
ü When users refresh applications, they see firstly latest version cached file.
ü The Updates happen in the background process. Do not interrupt to other process.
ü When Updates, it’s happen the previous version of the application is served until an update ready to use
Prerequisites to Supports Service Workers –
We must have the following Angular and CLI versions and also our web application must run in a web browser that supports service workers.
ü Angular 5 or later
ü Angular CLI 1.6 or later
I hope you are enjoying with this post! Please
share with you friends!! Thank you!!!