Ionic Cache is a caching service for Angular/Ionic apps that caches HTTP requests, observables, promises, and plain data. Version 6.0.3 is current. It uses Ionic Storage (IndexedDB, SQLite, WebSQL) as the backing store and supports configurable TTL, group invalidation, offline resilience, and delayed observable caching. It ships TypeScript types and requires @angular/common >=9.0.0, @angular/core >=9.0.0, and @ionic/storage-angular >=3 as peer dependencies. Key differentiators: tight Ionic/Angular integration, delayed observable pattern for seamless stale-while-revalidate behavior.
npm install ionic-cacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows full Angular module setup with CacheModule.forRoot and ionic-storage-angular, then basic HTTP request caching using CacheService.loadFromObservable.
Set a keyPrefix in CacheModule.forRoot({ keyPrefix: 'my-app-cache' }) to scope cache entries.Pass a config object even if empty: CacheModule.forRoot({}).For background refresh, use cache.loadFromDelayedObservable(cacheKey, request, group, ttl, 'all') instead.
Upgrade to Angular 9 or later.
Use descriptive, unique cache keys (e.g., URLs with query parameters).
Use the new signature: loadFromDelayedObservable(key, request, options) where options includes delayType.
Run: npm install @ionic/storage-angular (or yarn add @ionic/storage-angular).
Always provide a non-empty string as the first argument to loadFromObservable.
Ensure IonicStorageModule.forRoot() is imported in AppModule, and CacheService is used after app initialization.
Use HttpClient from '@angular/common/http' which auto-parses JSON. If using plain fetch, parse manually.