reactjs – 缓存破坏与创建反应应用程序
发布时间:2020-12-15 20:47:42 所属栏目:百科 来源:网络整理
导读:当我更新我的网站时,运行npm run build并将新文件上传到服务器我仍在查看我的网站的旧版本. 我的项目的回购是 https://github.com/Alfrex92/serverlessapps 没有React,我可以看到我的网站的新版本缓存破坏.我这样做: 上一个文件 link rel="stylesheet" href
当我更新我的网站时,运行npm run build并将新文件上传到服务器我仍在查看我的网站的旧版本.
我的项目的回购是 https://github.com/Alfrex92/serverlessapps 没有React,我可以看到我的网站的新版本缓存破坏.我这样做: 上一个文件 <link rel="stylesheet" href="/css/styles.css"> 新文件 <link rel="stylesheet" href="/css/styles.css?abcde"> 我怎么能做这样的事情或用create react app实现缓存清除? 在创建的github中有很多线程对此做出反应,但没有人有正确/简单的答案.
这可能是因为你的网络工作者.
如果查看index.js文件,可以看到 registerServiceWorker(); 从来不想知道它做了什么?如果我们看看它导入的文件,我们可以看到 // In production,we register a service worker to serve assets from local cache. // This lets the app load faster on subsequent visits in production,and gives // it offline capabilities. However,it also means that developers (and users) // will only see deployed updates on the "N+1" visit to a page,since previously // cached resources are updated in the background. // To learn more about the benefits of this model,read {URL} // This link also includes instructions on opting out of this behavior. 如果要删除Web工作者,请不要删除该行.导入取消注册并在您的文件而不是寄存器中调用它. import { unregister } from './registerServiceWorker'; 并告诉电话 unregister() 附:取消注册时,至少需要一次刷新才能使其正常工作 编辑:create-react-app v2现在默认禁用服务工作者 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |