我正在尝试禁用我的AngularJS应用程序中的缓存,但它不能与以下代码一起工作:
$http.get("myurl",{cache:false})当我使用"myurl&random="+Math.random()时,缓存是禁用的;但是,我想要一种不同的方法。
发布于 2016-07-05 14:29:15
这已经回答了here。
粘贴链接中的代码片段以供参考。
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';
}]);发布于 2017-11-19 15:54:53
下面是我所做的,只需将其更改为
$http.get("myurl",{headers:{'Cache-Control': 'no-cache'}})发布于 2016-07-05 14:25:15
试着这样做
$state(' 'app.name', {
url: '/name',
cache: false,
controller:'MainCtrl',
templateUrl:'templates/name.html'
})https://stackoverflow.com/questions/38196452
复制相似问题