简体   繁体   English

在服务器上更新应用程序后如何重新加载 vuejs

[英]How can you reload vuejs after application update on server

I have a scenario where there is a necessity that the users reload the vuejs app to get the latest vue app version when i update the whole application in the server including the backend APIs.我有一个场景,当我更新服务器中的整个应用程序(包括后端 API)时,用户必须重新加载 vuejs 应用程序以获取最新的 vue 应用程序版本。

Suppose there is a chance that a user using the vue app version 1.1 already on production, will still be continuing to use the same even after the update at server (ie to 1.2).假设用户使用已经在生产中的 vue 应用程序 1.1 版,即使在服务器更新(即到 1.2)后仍有可能继续使用相同的应用程序。 In such cases the backend APIs might have changed and it would break.在这种情况下,后端 API 可能已更改并且会中断。

Any short and easy ways/methods to solve the above?解决上述问题的任何简短而简单的方法/方法?

One way is to send the version number 1.1 or 1.2 in all our API requests to the backend.一种方法是将我们所有 API 请求中的版本号 1.1 或 1.2 发送到后端。 Then you check the version in the backend and send a special error if it is an old version.然后在后端检查版本,如果是旧版本,则发送特殊错误。 In the frontend you handle this special error by refreshing the page.在前端,您通过刷新页面来处理此特殊错误。 Also make sure that your new *.js files have a new name so the client browser will fetch the new version and not load any cached *.js files.还要确保您的新 *.js 文件具有新名称,以便客户端浏览器将获取新版本而不加载任何缓存的 *.js 文件。

This answer could have helpful information. 该答案可能会提供有用的信息。 It seems you want to invalidate the cached version of the site to ensure the user receives the up to date application? 您似乎想使网站的缓存版本无效,以确保用户收到最新的应用程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM