角IE缓存的问题为$ HTTP [英] Angular IE Caching issue for $http

查看:101
本文介绍了角IE缓存的问题为$ HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有这一切都从IE发送Ajax调用是由角缓存,我收到了 304响应所有后续调用。虽然要求是一样的,反应不是会是在我的情况是一样的。我想禁用此缓存。我试着加入缓存属性至$ http.get但它仍然没有帮助。如何解决这个问题的解决?

All the ajax calls that are sent from the IE are cached by Angular and I get a 304 response for all the subsequent calls . Though the request is the same, the response is not gonna be the same in my case. I wanna disable this cache. I tried adding the cache attribute to $http.get but still it didnt help. How can this issue be resolved?

推荐答案

,我关闭全局在$ httpProvider:

Instead of disabling caching for each single GET-request, I disable it globally in the $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';
}]);

这篇关于角IE缓存的问题为$ HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆