Angular 在IE 11中,5缓存问题
我们正在使用Angular 5,在我们的项目中,我们正在创建/修改UI中的值,并使用REST存储在数据库中 修改UI后,单击“保存”后。用户界面没有显示修改后的用户界面,而是显示上一个用户界面。当在IE中执行硬刷新(ctrl+F5)时,它将进行REST调用并显示正确的值。这只发生在IE 11中,在Chrome中运行良好 请让我知道,我们是否可以控制清除缓存只有这个应用程序的代码或任何其他建议是感激的 谢谢Angular 在IE 11中,5缓存问题,angular,internet-explorer,caching,browser-cache,Angular,Internet Explorer,Caching,Browser Cache,我们正在使用Angular 5,在我们的项目中,我们正在创建/修改UI中的值,并使用REST存储在数据库中 修改UI后,单击“保存”后。用户界面没有显示修改后的用户界面,而是显示上一个用户界面。当在IE中执行硬刷新(ctrl+F5)时,它将进行REST调用并显示正确的值。这只发生在IE 11中,在Chrome中运行良好 请让我知道,我们是否可以控制清除缓存只有这个应用程序的代码或任何其他建议是感激的 谢谢 vinod要解决您的问题,您需要覆盖请求选项并设置“缓存控制”:“无缓存”,如下所示 自定
vinod要解决您的问题,您需要覆盖
请求选项
并设置“缓存控制”:“无缓存”
,如下所示
自定义请求选项。ts
import { Injectable } from '@angular/core';
import { BaseRequestOptions, Headers } from '@angular/http';
@Injectable()
export class CustomRequestOptions extends BaseRequestOptions {
headers = new Headers({
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': 'Sat, 01 Jan 2000 00:00:00 GMT'
});
}
@NgModule({
...
providers: [
...
{ provide: RequestOptions, useClass: CustomRequestOptions }
]
})
you.app.module.ts
import { Injectable } from '@angular/core';
import { BaseRequestOptions, Headers } from '@angular/http';
@Injectable()
export class CustomRequestOptions extends BaseRequestOptions {
headers = new Headers({
'Cache-Control': 'no-cache',
'Pragma': 'no-cache',
'Expires': 'Sat, 01 Jan 2000 00:00:00 GMT'
});
}
@NgModule({
...
providers: [
...
{ provide: RequestOptions, useClass: CustomRequestOptions }
]
})
希望这有帮助 您正在使用Http的HttpClient吗?我正在使用HttpClient