noa*_*oah 5 internet-explorer http angularjs
我有一个角度应用程序,它对服务器进行HTTP GET调用.它适用于Chrome和Firefox.但是,我发现IE缓存了GET响应,在我执行POST后,我需要调用相同的GET请求并获取新的更新响应,但IE会缓存它.我想禁用IE的缓存.我试过用了
'If-None-Match': '*'
Run Code Online (Sandbox Code Playgroud)
我的GET调用请求标头,但随后禁用所有内容的缓存.有没有办法只为IE有条件地做这件事?或者还有另一种方法可以禁用它吗?
$http,在 IE 中。没有响应代码 200 或 304。它仅使用本地缓存。
尝试将标头添加到 $httpProvider。
angular.module(ApplicationConfiguration.applicationModuleName)
.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);
Run Code Online (Sandbox Code Playgroud)