zoukankan      html  css  js  c++  java
  • AngularJS 中设置 AJAX get 请求不缓存的方法

    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

  • 相关阅读:
    XSS初探
    简单的HTTP服务实现
    WinForm“假死”问题汇总
    Access 数据库的数据类型
    C#应用调试C++ dll的方法
    Visual Studio远程调试
    【汇总】C#编程技巧
    SQL Server常见问题及解决方法
    java订单生成工具类
    JAVA-学习路线
  • 原文地址:https://www.cnblogs.com/jroger/p/4478219.html
Copyright © 2011-2022 走看看