【问题标题】:Why it's need a hard reload when I update react app server为什么当我更新反应应用服务器时需要重新加载
【发布时间】:2021-06-29 05:44:58
【问题描述】:

每次我用一些更改更新应用服务器时,我的应用都会重新加载。否则,我看不到更改。

在我看来,这是个问题。

我的用户不知道我何时更新服务器,我无法告诉我的用户您需要硬重新加载。

现在我该如何解决这个问题?

这是我的依赖项:

"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.58",
"@material-ui/styles": "^4.11.4",
"@sentry/react": "^6.2.0",
"@sentry/tracing": "^6.2.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"axios-hooks": "^2.1.0",
"bootstrap": "^4.5.0",
"bootstrap-daterangepicker": "^3.1.0",
"chart.js": "^2.9.3",
"chroma-js": "^2.1.0",
"date-fns": "^2.22.1",
"gh-pages": "^2.2.0",
"history": "^4.10.1",
"html-react-parser": "^0.13.0",
"i": "^0.3.6",
"i18next": "^19.5.1",
"i18next-browser-languagedetector": "^5.0.0",
"i18next-http-backend": "^1.0.15",
"i18next-xhr-backend": "^3.2.2",
"jwt-decode": "^3.0.0-beta.2",
"lodash.throttle": "^4.1.1",
"moment": "^2.27.0",
"node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-app-polyfill": "^1.0.6",
"react-bootstrap": "^1.0.1",
"react-bootstrap-4-pagination": "^1.0.3",
"react-bootstrap-datetimerangepicker": "^2.0.4",
"react-chartjs-2": "^2.11.1",
"react-circular-progressbar": "^2.0.3",
"react-color": "^2.18.1",
"react-cookie-consent": "^6.2.3",
"react-date-range": "^1.2.0",
"react-datepicker": "^3.4.1",
"react-dom": "^16.13.1",
"react-flags-select": "^1.1.12",
"react-ga": "^3.3.0",
"react-google-login": "^5.2.2",
"react-helmet": "^6.1.0",
"react-hook-form": "^6.3.1",
"react-html-parser": "^2.0.2",
"react-i18next": "^11.7.0",
"react-moment": "^0.9.7",
"react-nested-loader": "^2.2.1",
"react-paginate": "^7.1.0",
"react-pro-sidebar": "^0.6.0",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"react-script-tag": "^1.1.2",
"react-scripts": "^3.4.3",
"react-scroll": "^1.7.16",
"react-select": "^3.1.0",
"react-select-country-list": "^2.2.1",
"react-tabs": "^3.1.1",
"reactcss": "^1.2.3",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"semantic-ui-react": "^0.88.2",
"styled-components": "^5.2.3",
"swiper": "^6.7.0",
"universal-cookie": "^4.0.3",
"use-dynamic-refs": "^1.0.0",
"validator": "^13.1.1"

},

【问题讨论】:

    标签: javascript reactjs create-react-app


    【解决方案1】:

    在客户端,许多 JS 块和资产是从服务器获取的。为了加快加载速度,在服务器和浏览器上都使用了缓存。 当您重新启动服务器时,旧缓存可能仍在使用中。如果没有自动完成,则需要硬刷新才能删除旧缓存。您可以更改服务器缓存时间/策略来解决此问题。 或者在客户端使用 service worker 来更快更好地管理块

    【讨论】:

      猜你喜欢
      • 2018-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-25
      相关资源
      最近更新 更多