In Internet & Development

Today I needed a client side caching plugin for Ionic 2. I’m currently developing an app for a customer, and wanted to speed things up a little and save bandwidth by the way.

Caching with RxJs

Since I’m using RxJs with Observables I searched for a solution or an operation named something like cache() but didn’t find one. After a bit of googling I found this article:

The solution provided there is the following:

  getTools(): Observable<Tool[]> {

    if (!{
      const queryUrl: string = this.BASE_URL + '/tools'; = this.http.get(queryUrl)
        .map((response: Response) => {
          return (<any>response.json()) => {
            return new Tool(,;


Although this works, I’m missing the time based cache eviction strategy. This is basically in-memory only and doesn’t survive a page reload.

npm package: ionic-cache

Then I found this great project which seemed to be exactly what I’m searching for:

From the commits it seems pretty active and well documented. So I gave it a try and am very happy with it. Thanks for developing this great plugin!

Recent Posts