从IE发送的所有ajax调用都由Angular缓存,后续所有调用我都会得到304 response
分.虽然请求是一样的,但在我的情况下,响应是不一样的.我想禁用这个缓存.我try 将cache attribute
添加到$http.但还是没用.如何解决这个问题?
从IE发送的所有ajax调用都由Angular缓存,后续所有调用我都会得到304 response
分.虽然请求是一样的,但在我的情况下,响应是不一样的.我想禁用这个缓存.我try 将cache attribute
添加到$http.但还是没用.如何解决这个问题?
我没有 for each GET请求禁用缓存,而是在$httpProvider中全局禁用它:
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
// Answer edited to include suggestions from comments
// because previous version of code introduced browser-related errors
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
// extra
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);