我正在编写一个 Angular SPA 应用程序,它使用 HttpClient 从我的后端获取值。
告诉它不要缓存的简单方法是什么?我第一次询问它获得了值,然后它拒绝进行后续查询。
谢谢, 格里
最佳答案
使用元 HTML 标签,禁用浏览器缓存:-
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
或者,
在 http
请求中添加 headers
为:-
headers = new Headers({
'Cache-Control': 'no-cache, no-store, must-revalidate, post-
check=0, pre-check=0',
'Pragma': 'no-cache',
'Expires': '0'
});
关于angular - 如何在 Angular 6 中使用 HttpClient get 禁用缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53232382/