I'm clearly doing something wrong (stupid). Here is my service and controller. It works the first-time but not navigating back, it doesn't. Suggestions:
.service('rackService', function ($http, DSCacheFactory, $q) { // added $q
DSCacheFactory('dataCache', {
maxAge: 900000, // Items added to this cache expire after 15 minutes.
cacheFlushInterval: 3600000, // This cache will clear itself every hour.
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
});
return {
getData: function (id) {
var deferred = $q.defer(),
start = new Date().getTime(),
dataCache = DSCacheFactory.get('dataCache');
// Now that control of inserting/removing from the cache is in our hands,
// we can interact with the data in "dataCache" outside of this context,
// e.g. Modify the data after it has been returned from the server and
// save those modifications to the cache.
if (dataCache.get(id)) {
console.log('time taken from cache: ' + (new Date().getTime() - start) + 'ms');
deferred.resolve(dataCache.get(id));
} else {
$http.get('
https://rack').success(function (data) {