服务器上的应用程序更新后如何重新加载vuejs [英] How can you reload vuejs after application update on server

查看:65
本文介绍了服务器上的应用程序更新后如何重新加载vuejs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,当我在服务器中更新包括后端API的整个应用程序时,用户有必要重新加载vuejs应用程序以获取最新的vue应用程序版本.

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.

假设使用已经在生产中的vue应用程序版本1.1的用户即使在服务器上进行更新(即升级到1.2)之后,仍然有可能继续使用该版本.在这种情况下,后端API可能会更改,并且会中断.

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). In such cases the backend APIs might have changed and it would break.

解决上述问题的任何简便方法/方法?

Any short and easy ways/methods to solve the above?

推荐答案

一种方法是将所有API请求中的版本号1.1或1.2发送到后端.然后,您在后端检查版本,如果它是旧版本,则发送特殊错误.在前端,您可以通过刷新页面来处理此特殊错误.还要确保新的* .js文件具有新名称,以便客户端浏览器将获取新版本,并且不加载任何缓存的* .js文件.

One way is to send the version number 1.1 or 1.2 in all our API requests to the backend. 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.

这篇关于服务器上的应用程序更新后如何重新加载vuejs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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