我正在尝试向资源添加缓存,但在每次调用时,都会发出新的ajax请求。这里:
app.factory('States', function($resource,$locale,$cacheFactory) {
var cache = $cacheFactory('statesCache');
var StatesService = $resource( "api/ref/states-:country", {}, {
query: {
cache: cache, //With true it doesn't work either
method: 'GET',
isArray: true
}
});
return {
getList: function( country ) {
console.log( cache.info() );
return StatesService.query({
country: (country || "CA").toLowerCase()
});
}
}
});
然后每次调用States.getList( "CA" );
都会触发一个新的Http请求。控制台说每次客户缓存大小仍为0:Object {id: "statesCache", size: 0}
Angular version 是v1.2.0-rc.3 是1.0.8
答案 0 :(得分:1)
问题是Chrome没有使角度文件的缓存失效。它仍然加载角1.0.8。
我已经清理了缓存并且正确地更新了角度资源版本,现在它可以正常工作。