apollographql / apollo-cache-persist

🎏 Simple persistence for all Apollo Cache implementations
MIT License
1.39k stars 118 forks source link

Setting the value of 'apollo-cache-persist' exceeded the quota #31

Closed debianw closed 6 years ago

debianw commented 6 years ago

Hi, I'm having this exception Setting the value of 'apollo-cache-persist' exceeded the quota and I already set maxSize to false for unlimited cache size but still getting this exception.

By the way I'm using localStorage

This is my cache persistor Object:

const persistor = new CachePersistor({
  cache,
  storage: window.localStorage,
  debug: true,
  maxSize: false
});
jamesreggio commented 6 years ago

Hi @debianw —

Browsers generally set quotas on the amount of data that a page can store in localStorage. These quotas vary from browser-to-browser, but there's not much you can do to get around them. (e.g., in Chrome, it's hard-set to 5MB.)

My advice would be to set a maxSize that is smaller than these quotas to ensure that your app doesn't experience any unhandled exceptions. Generally, if the cache has grown to several megabytes in size, there's probably a lot of stale/orphaned data in it, and it may actually improve performance to let it be purged and repopulated at that point.

chengyin commented 5 years ago

For everyone else's reference: on web localforage, which uses IndexDB has a much higher quota.