Force Ember Data to skip cache with reload: true
In Ember Data 1.13 many of the store methods for retrieving data changed to become more constent. However I missed a key aspect of those changes and somehow it has not effected my everyday Ember until now.
The way findAll
and findRecord
behave in regards to caching was changed so that the behavior would facilitate the most common use case. The behavior that the Ember Data team has implemented is:
- First time store.find is called, fetch new data
- Next time return cached data
- Fetch new data in the background and update
This means that your app might seem to behave fine when you migrate to Ember[-Data] 1.13 or 2.* but there could be subtle places where hard refreshes on certain show pages makes navigating back to an index page render without all the other records loaded. This just happened with the EmberWeekend site.
The solution was to simply add { reload: true }
to the options of your findAll
queries.
store.findAll('user', { reload: true }); //enforces getting fresh data
Tweet