【发布时间】:2013-06-21 15:34:02
【问题描述】:
我有一个用 ASP.NET 编写的 Web API,我正在通过 AngularJS $http 使用它。
我已经在我的 AngularJS 工厂中启用了缓存,如下所示,但每个请求仍然返回 200 的响应,而不是 200 (from cache) 或 304(每个请求我的意思是在同一页面,重新访问我已经访问过的包含 Web API 请求的页面,刷新所述页面等)。
angular.module('mapModule')
.factory('GoogleMapService', ['$http', function ($http) {
var googleMapService = {
getTags: function () {
// $http returns a promise, which has a 'then' function, which also returns a promise
return $http({ cache: true, dataType: 'json', url: '/api/map/GetTags', method: 'GET', data: '' })
.then(function (response) {
return response.data;
});
};
return googleMapService;
}]);
我是否遗漏了 AngularJS 方面的一些东西?或者这是一个 Web API 问题。还是两者兼有?
【问题讨论】:
标签: c# caching angularjs asp.net-web-api