部署的React Web应用程序需要硬刷新 [英] deployed react web app requires hard refresh

查看:102
本文介绍了部署的React Web应用程序需要硬刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用create-react-app(v1.0.13)引导。每当我更新源&重新部署用户需要硬刷新以获取新内容。我在index.html中包含了非缓存头:

Bootstrapped with create-react-app (v1.0.13). Whenever I update the source & redeploy users need to hard refresh to get the new content. I've included non-cache header in index.html:

< meta http-equiv = Cache-Control content = no -store />

&关闭提供的服务人员。部署前,还要在构建文件夹中更改.js文件名(并在index.html中引用)。

& turned off provided service workers. Also change the .js filename (and reference in index.html) in build folder before deploying.

推荐答案

未来-您只需要

{unregister} from ./registerServiceWorker

unregister();

这帮助我的create-react-app与gh-pages和netlify等主机一起工作。

This helped my create-react-app work with hosts like gh-pages and netlify.

这篇关于部署的React Web应用程序需要硬刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆