Reputation: 1466
As per angular official doc https://angular.io/guide/service-worker-intro
Service workers function as a network proxy. They intercept all outgoing HTTP requests made by the application and can choose how to respond to them. For example, they can query a local cache and deliver a cached response if one is available. Proxying isn't limited to requests made through programmatic APIs, such as fetch; it also includes resources referenced in HTML and even the initial request to index.html. Service worker-based caching is thus completely programmable and doesn't rely on server-specified caching headers.
As per my understanding from above, it can be used for slow network connection or when site goes offline.
I want to know if it is possible to avail caching
mechanism so that user will only see cached pages when visits second time and site is still online. Pages should be updated if there are changes in server side data. I want to use primarily for app performance.
Most examples I got, it referred only for slow network or offline site.
I am using Angular 7.2.11
Upvotes: 2
Views: 500
Reputation: 629
I believe you are looking for a progressive web app. basically you want to store some data in cache and the rest in browser's web storage. depending on architecture of your app, data size and requirements you have to decide where to store the data and when to access it. have a look at the link below and comment if you need further details :) https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook
Upvotes: 1