How can we help you today?

Is there a way to force data into the cache?

D

Daniel Roizman

started a topic
over 4 years ago

My understanding is that when you .fetch data, the data is cached locally so that when you are offline, you can still access it. When my app starts up, there's a bunch of collection that I need to pull from, but to optimize things, I want to use an endpoint that aggregates all the data into a single request, and then sort the data into the various Backbone collections on the client side.

How can I cache the collections locally if the data came from an endpoint? I'd like to tap into Kinvey's mechanisms rather than write my own around localStorage.

Mark

said
over 4 years ago

The local cache is designed to work with collection data only, not endpoints. There are probably hacky ways to do what you want, but I highly recommend using your own solution for this as you might run into situations where e.g. the library is trying to sync your endpoint data.

D

Daniel Roizman

said
over 4 years ago

So as a less hacky solution, I created an empty collection and in the collection hooks, I'm running the same code I was running on my endpoint, passing the parameters in via the query.