首页 > Web开发 > 详细

AngularJS 中设置 AJAX get 请求不缓存的方法

时间:2015-05-05 10:28:46      阅读:427      评论:0      收藏:0      [点我收藏+]
var app = angular.module(‘manager‘, [‘ngRoute‘]);

app.config([‘$routeProvider‘, function($routeProvider) {
    $routeProvider
    .when("/index", {
            templateUrl: "/Templates/index.html",
            controller: IndexCtrl
        })
    .when("/search", {
            templateUrl: "/Templates/search.html",
            controller: SearchCtrl
    })
    .when("/baseSettings", {
            templateUrl: "/Templates/baseSettings.html",
            controller: BaseSettings
    })
    .when("/aboutTech", {
            templateUrl: "/Templates/aboutTech.html",
            controller: AboutTech
    })
    .otherwise({ redirectTo: "/index" });
}]);

app.config(["$httpProvider", function($httpProvider) {
    if( !$httpProvider.defaults.headers.get ) {
        $httpProvider.defaults.headers.get = {};
    }

    // 禁用 IE AJAX 请求缓存
    $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‘;
}]);

参考:

http://stackoverflow.com/questions/16098430/angular-ie-caching-issue-for-http

AngularJS 中设置 AJAX get 请求不缓存的方法

原文:http://www.cnblogs.com/jRoger/p/4478219.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!