$http
是否有任何提示来显示响应是否从缓存中获取?
例如,假设我已经进行了以下两个调用:
$http.get({url, cache: true).then(function(response, ..., moreData) { alert(moreData.fromCache) }) //alerts false
$http.get({url, cache: true).then(function(response, ..., moreData) { alert(moreData.fromCache) }) //alerts true
正如您所看到的,第一个调用实际上执行了一个ajax调用,因此它不是来自缓存的,第二个调用从缓存中获取数据,因此它会弹出true。