Angular在IE 11中的GET请求从缓存中获取数据。
创始人
2024-10-30 20:00:55
0

在Angular中,可以使用http请求的cache选项来控制是否从缓存中获取数据。

以下是一个示例代码,展示如何在IE 11中使用Angular进行GET请求并从缓存中获取数据:

import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Component({
  selector: 'app-example',
  template: `
    
    
{{ item }}
`, }) export class ExampleComponent implements OnInit { data: any[]; constructor(private http: HttpClient) {} ngOnInit() {} getData() { const url = 'https://api.example.com/data'; // 替换为实际的API URL const headers = new HttpHeaders() .set('Cache-Control', 'no-cache') // 禁用缓存 .set('Pragma', 'no-cache') .set('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT'); this.http .get(url, { headers, responseType: 'json', withCredentials: true }) .subscribe((response) => { this.data = response; }); } }

在上述代码中,我们通过设置请求头中的Cache-ControlPragmaExpires来禁用缓存。这样,即使在IE 11中,GET请求也不会从缓存中获取数据。

相关内容

热门资讯

实操分享!wepoker养号规... 《实操分享!wepoker养号规律,wepoker游戏安装教程,透明挂教程(有挂技巧)》 wepok...
记者揭秘!wepoker私人局... 《记者揭秘!wepoker私人局俱乐部辅助,impoker辅助,必赢教程(有挂透明)》 wepoke...
总算了解!wepoker透视a... 总算了解!wepoker透视app下载,wpk辅助,可靠技巧(有挂方法);wepoker透视app下...
玩家必看!哈糖大菠萝软件下载,... 玩家必看!哈糖大菠萝软件下载,aapoker辅助软件合法吗,详细教程(有挂辅助);实战中需综合运用上...
必备科技!wepoker俱乐部... 必备科技!wepoker俱乐部辅助,wepoker怎么获得好牌,细节揭秘(有挂软件);wepoker...
今日百科!佛手在线有挂吗,wp... 今日百科!佛手在线有挂吗,wpk透视辅助,可靠技巧(有挂神器);《WPK辅助透视》‌:支持手机实时对...
一起来探讨!德州辅助工具到底怎... 1、一起来探讨!德州辅助工具到底怎么样,pokemmo辅助工具,安装教程(有挂神器)(UU poke...
玩家必备教程!wejoker黑... 玩家必备教程!wejoker黑侠辅助器,pokemmo手机版脚本,切实教程(有挂神器);人气非常高,...
实操分享!cloudpoker... 自定义cloudpoker怎么开挂系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用...
总算清楚!pokemmo脚本辅... 总算清楚!pokemmo脚本辅助下载,hhpoker软件安装包,可靠教程(有挂方法)1、许多玩家不知...