zoukankan      html  css  js  c++  java
  • AngularJS在IE下页面缓存问题

    问题:

    在使用AngularJS发出请求(GET)获取服务端数据,然后再绑定到页面中,你会发现在IE中总是显示原来的数据结果。这时候我们就会知道,IE做了缓存。

    解决办法:

    我们可以在AngularJS的配置中通过$httpProvider来设置其不缓存。具体如下所示:

    ngApp.config(function ($httpProvider) {
      // Initialize get if not there
      if (!$httpProvider.defaults.headers.get) {
        $httpProvider.defaults.headers.get = {};
      }
      // Enables Request.IsAjaxRequest() in ASP.NET MVC
      $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
      //禁用IE对ajax的缓存
      $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
      $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
    });
     

  • 相关阅读:
    java oop
    traceroute
    ping
    ICMP Internet控制报文协议
    window,centos双系统坏了
    bcm53344 gpio驱动分析
    ioctl参数cmd=2错误
    BCM_GPIO驱动测试
    C++ 类和对象
    C++ 内存管理
  • 原文地址:https://www.cnblogs.com/ideacore/p/8854540.html
Copyright © 2011-2022 走看看