angelnikolov / ts-cacheable

Observable/Promise Cache Decorator
https://npmjs.com/package/ts-cacheable
ISC License
340 stars 42 forks source link

When browser close, it will reset the cache. #90

Closed iconixws closed 4 years ago

iconixws commented 4 years ago

We have implemented ngx-cacheable for our website https://www.matrimonyone.com. Its works perfectly fine until we close browser tab or browser. When we open website again, it will reset the cache. To reproduce this issue please follow below steps.

  1. Open https://www.matrimonyone.com, in footer, click on contact us then feedback.
  2. Click again on Contact us, data will load from caching.
  3. Close the browser and again open the website.
  4. Click on contact us in footer, you will see data is loading from database. (Expected Behaviour: It should load from Cache)
iconixws commented 4 years ago

We find out the solutions and closing this issue. Below is the solutions in app.component.ts

import { GlobalCacheConfig, DOMStorageStrategy } from 'ngx-cacheable';

constructor() {
GlobalCacheConfig.storageStrategy = DOMStorageStrategy;
}