React 应用程序中的缓存形成

问题描述 投票:0回答:1

在我的反应应用程序中,当我更改一些数据时,它不会立即反映。缓存正在形成,仅当我在网络选项卡中禁用缓存重新加载页面并通过在网络选项卡中启用缓存再次刷新时才会反映。在其他用户端也是如此,我需要反映更改。我需要我的更改同时反映在人力资源端和用户端。我尝试使用 html 元标记来清除 index.html 中的缓存

reactjs browser-cache
1个回答
0
投票

尝试设置-

对于 HTML-

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"> 

或者在 Nodejs 中-

 response.setHeader("Cache-Control", "no-cache, no-store,
 must-revalidate"); // HTTP 1.1. response.setHeader("Pragma",
 "no-cache"); // HTTP 1.0. response.setHeader("Expires", "0"); //
 Proxies.
© www.soinside.com 2019 - 2024. All rights reserved.