Mohamed Sahir
Mohamed Sahir

Reputation: 2543

Best Mechanism(Way) to Cache in angular4 service call data for every 20 minutes? if service is not available?

I have a angular service call to webapi , if webapi is got down , have to load the data from cache and the cache is expire after 20 minutes.

Which is better way to store the data?cache and webstorage is same or different technique? if same, angular4 core have cache api without plugins?

LocalStorage - store upto 5 MB and lifetime clear the data of browser, How it will be different from applicationcache?. SessioStorage - lifetime upto browser closes and in current tab?How it will be different from cache?

In angular 1 ,cachefactory and templatecache for caching technique? In angular2 ,how to cache by using core angular without any third party.

How to see the cache data in other browser and in IE browsers?

if service api not available , cache the data for 20 minutes and expire after 20 minutes? which mechanism is best to handle this situation (webstorage or cache or In memory data service or cookies)

Data Size is 2 MB Object. Here is product service?

_ProductUrl ="http://www.testapi.com/api/product";
    getProduct(): Observable <IProduct[]>{   
      return this._http.get(this._ProductUrl)
        .map((response:Response) =>  <IProduct[]> response.json())
        .catch(this.handleError);

}  

product.component.ts

ngOnInit(){
this._productService.getProduct())
  .subscribe((response) => {
this.productData = response;
}),(err)=> {this.errorMsg =<any>err};

Upvotes: 2

Views: 598

Answers (0)

Related Questions