local-storageapollo-clientapollo-cache-inmemory

Where should store auth token: Apollo Cache or Local Storage?


Since Apollo has Apollo Cache for storing local data. I want to store auth token inside the Apollo cache instead of local storage. By store to Apollo Cache, help me clear auth token and other caching data when user logout without caring about local storage data.

My question is: Is it OK if I store auth token in Apollo Cache? Because example of Authentication from Apollo website is using local storage for storing auth token, this make me confusing.


Solution

  • I decided to store auth token in Local Storage instead of Apollo Cache because I made benchmark to measure speed of retrieving token from Local Storage and Apollo Cache,result is: retrieve from Local Storage faster than Apollo Cache around 3 ~ 4 times