Cache persistence for Apollo Client 2.0 <https://...
# prisma-whats-new
s
Cache persistence for Apollo Client 2.0 https://dev-blog.apollodata.com/announcing-apollo-cache-persist-cb05aec16325 Looks like Apollo 2.0 has a home grown solution for offline support. Has anyone tried using this and maybe have a sample to show?
👍 3
l
I'm using it in development. It's worked extremely well.
s
great is it just a matter of adding import { InMemoryCache } from ‘apollo-cache-inmemory’; import { persistCache } from ‘apollo-cache-persist’; // Set up your cache. const cache = new InMemoryCache({...}); // Set up cache persistence. persistCache({ cache, storage: window.localStorage, }); ........... or is there more suggestions on getting things to work properly
l
It's simply
Copy code
persistCache({
  cache,
  storage: window.localStorage
})
after the cache is instantiated. It'll listen to changes and update local storage
s
thanks - do you use cache size controls such as maxSize and where if so do you add this?
l
I have not. I believe the max of local storage is 10 megabytes though