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

相关内容

热门资讯

透视了解!德州hhpoker是... 透视了解!德州hhpoker是真的吗,hhpkoer辅助挂是真的吗-原来真的有辅助方法(哔哩哔哩)1...
透视曝光!hhpoker透视方... 透视曝光!hhpoker透视方法,hhpoker有没有作弊辅助-本来真的有辅助神器(哔哩哔哩)1、金...
透视详情!wpk是真的还是假的... 透视详情!wpk是真的还是假的,wpk真的有透视嘛-本来存在有辅助工具(哔哩哔哩)1、实时透视辅助更...
透视揭幕!购买的wpk辅助在哪... 透视揭幕!购买的wpk辅助在哪里下载,wpk软件是真的吗-真是一直总是有辅助插件(哔哩哔哩)是不是有...
透视分享!wepoker有没有... 透视分享!wepoker有没有挂,wepoker数据分析-一贯是真的有辅助脚本(哔哩哔哩)1、免费脚...
透视了解!wepoker私人局... 透视了解!wepoker私人局有透视吗,WePoKer辅助器-确实一直都是有辅助教程(哔哩哔哩)1、...
透视辅助!wpk真的有透视嘛,... 透视辅助!wpk真的有透视嘛,wpk真吗-本来是真的有辅助app(哔哩哔哩)1、透视辅助!wpk真的...
透视详情!wepoker私人局... 透视详情!wepoker私人局辅助器怎么用,wepokerh5破解-确实一直都是有辅助工具(哔哩哔哩...
透视详情!智星德州插件2024... 透视详情!智星德州插件2024最新版,pokemmo脚本-一直真的有辅助脚本(哔哩哔哩)1、上手简单...
透视分享!hhpkoer辅助挂... 透视分享!hhpkoer辅助挂是真的吗,hhpoker德州牛仔视频-果然有辅助神器(哔哩哔哩)1、完...