1. 24
    Provide quick app start-up times by syncing the Apollo cache with local storage
    7m 14s

Provide quick app start-up times by syncing the Apollo cache with local storage

Share this video with your friends

Send Tweet

Whenever we start up the app, it has to wait on all its initial queries to resolve. Even after that's done, as we click around the app and load new notes in the cache, all of that data is lost on refresh, because it's kept in memory. In this lesson we'll look at using the "apollo3-cache-persist" package, to set-up a syncing mechanism that automatically saves any changes to the Apollo cache in local storage, and then restores it when the app starts. This results in quick start-up times. We'll also look at setting global "cache-and-network" fetch policies that ensure our data is kept fresh and updated with the backend. We'll also set-up a secondary "nextFetchPolicy" that reverts the global query fetch policy back to the default "cache-first" once the app bootstraps.