Access data offline by caching API response

I am building and app which will be talking to API to show the data,

I want to show already fetched data while the app is offline. Whats the best way to go about it.

Is only $http {cache : true} will be enough. whats your preferred library or tutorial to do this.

I have checked there are topics about PouchDB but I dont want to maintain a db on client side, any way to just cache the api response will be enough for this app

To store client-side and persistent data, you can’t use the $http {cache : true} , which just caches the data for the current session.$http deirective internally uses the $cachefactory to catch the responses.you can’t retrieve that data when you relaunch the application in another session.

Better choose browser localstorage/sqllite/pouchdb options for offline data access.

thanks, I think local-storage will be enough for this, any library for localstorage?

But there is limit of 3-5mb for local-storage, that can cause issue, for example. If I have 20 endpoints and all data will be cached, then it will surely cross this limit.

another option is SQLlite, but what should be the structure of table to hold the response cache. I was thinking something like this

cache table

url : varchar:unique
body : text
created_at : timestamp
updated_at : timestamp

any suggestion, what will be better way to implement API response cache in SQLlite?

If your data can be easily put into an sqlite, do this, otherwise, I’ve used with success angular-cache and DSCacheFactory.