强制客户端重新加载我的 bundle.js [英] Force clients to reload my bundle.js

查看:31
本文介绍了强制客户端重新加载我的 bundle.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React 和 Webpack 创建一个完全前端的应用程序.我只是对我的构建进行了一些更改.现在我担心的是我的用户不会使用最新的包,而是他们浏览器缓存的包.我怎样才能让他们加载最新的包?

I'm using React and Webpack to create a completely front-end application. I just made some changes to my build. Now my concern is that my users won't get to use the latest bundle but the cached bundle by their browsers. How can I get them to load the latest bundle?

推荐答案

不建议在客户端浏览器中添加强制加载资源的代码,因为这会导致应用程序渲染缓慢.

It is not recommended to add a code for loading assets forcefully in client browser as this will result in the slow rendering of application.

您想要实现的任务可以通过在脚本标记上添加新的查询参数 version 来完成,并在您想要加载新代码时更改该版本.

The task you want to achieve can be done by adding a new query parameter version on your script tag and change that version whenever you want to load new code.

类似的东西

<script type="text/javascript" src="myfile.js?REVISION"></script>

这篇关于强制客户端重新加载我的 bundle.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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