【发布时间】:2013-05-28 01:07:14
【问题描述】:
我在控制器中使用了一个小型 repo factory 服务:
我的控制器:
angular.module('repoApp')
.controller('MainCtrl', function ($scope, $repoService) {
$scope.repos = $repoService.getRepos();
});
我的工厂:
angular.module('repoApp')
.factory('$repoService', function ($http) {
var repos =
// $http.defaults.headers['If-Modified-Since'] = 'Sat, 01 Jun 2013 1:31:30 GMT';
$http.jsonp('https://api.github.com/repos/mojombo/jekyll/issues?state=closed&callback=JSON_CALLBACK',
{
cache: true
}
);
// Public API here
return {
getRepos: function () {
return repos.then(function(repoData) {
return repoData.data.data;
});
}
};
});
这很好 - 我得到了结果,但每次浏览器刷新时,我最终都会得到 200 响应而不是 304。我做错了什么?
我也尝试过使用JSON_SINGLE_CALLBACK 中提到的this closed issue。
【问题讨论】:
标签: caching angularjs jsonp github-api