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请求也不会从缓存中获取数据。

相关内容

热门资讯

揭露透视!哈糖大菠萝攻略,hh... 揭露透视!哈糖大菠萝攻略,hhpoker是内部控制吗,教材教程(揭秘有挂)-哔哩哔哩1、操作简单,无...
教你透视!智星德州插件最新版本... 教你透视!智星德州插件最新版本更新内容详解,wepoker买钻石有用吗,手册教程(详细教程)-哔哩哔...
关于透视!hh poker软件... 关于透视!hh poker软件,菠萝德普辅助器免费版在哪里,学习教程(有挂方略)-哔哩哔哩1、菠萝德...
详细透视!wepoker安装教... 详细透视!wepoker安装教程,hhpoker作必弊码,策略教程(新版有挂)-哔哩哔哩;1、许多玩...
普及透视!wejoker黑侠辅... 普及透视!wejoker黑侠辅助器,hhpoker德州牛仔视频,指南教程(有挂秘笈)-哔哩哔哩在进入...
总结透视!wpk透视辅助下载,... 总结透视!wpk透视辅助下载,哈糖大菠萝破解器,法门教程(有挂技巧)-哔哩哔哩1、许多玩家不知道哈糖...
解迷透视!德扑HHpoker有... 解迷透视!德扑HHpoker有挂吗,wepoker能不能透视,秘籍教程(的确有挂)-哔哩哔哩1、不需...
推荐透视!pokermaste... 推荐透视!pokermaster辅助器,poker master辅助,方式教程(有挂教学)-哔哩哔哩...
教你透视!hhpoker德州挂... 教你透视!hhpoker德州挂真的有吗,wepoker高级辅助,经验教程(有挂细节)-哔哩哔哩1、超...
解密透视!哈糖大菠萝可以开挂吗... 解密透视!哈糖大菠萝可以开挂吗,模拟器打开hhpoker,教材教程(确实有挂)-哔哩哔哩哈糖大菠萝可...