Search code examples
angularjscachefactory

Is their any size limit to AngularJS $cacheFactory?


Should I be considering flushing the cache from time to time? Or I can cache all my API responses?


Solution

  • 1. Should I be considering flushing the cache from time to time?

    No. Because $cacheFactory will destroy all the data once the session has been closed. Or if you want to flush manually then you can use destroy method.

    destroy() - Removes references to this cache from $cacheFactory.

    removeAll() - Removes all cached values.

    2. I can cache all my API responses?

    This is possible in two ways as follows.

    1. $localStorage - If your goal is to store client-side and persistent data.
    2. $cacheFactory - Data exist only for current session.