gpt4 book ai didi

javascript - 在生产服务器上刷新 angularjs 更改的问题

转载 作者:行者123 更新时间:2023-12-04 11:53:11 26 4
gpt4 key购买 nike

当我对我的 angularjs 应用程序进行更改时,我遇到了一个反复出现的问题。问题是,如果我想播种我所做的更改,我必须刷新页面。这是一个问题,因为我不希望我的用户必须刷新页面(他们可能不知道这样做)。他们可能认为该网站已损坏。我是否可以遵循某种 Angular Directive(指令)或流程,让我的 UI 更改反射(reflect)在我的生产服务器上,而无需我的用户刷新页面?

最佳答案

您可以查看几种解决方案,

  • 您的问题在这里有类似的答案:

  • AngularJS disable partial caching on dev machine

    引用该帖子上接受的答案:

    "here's one way to always automatically clear the cache whenever the ng-view content changes"

    myApp.run(function($rootScope, $templateCache) {
    $rootScope.$on('$viewContentLoaded', function() {
    $templateCache.removeAll();
    });
    });

  • 也可以在这里找到非 Angular 解决方案:

  • Force browser to clear cache

    引用该帖子的最佳答案(Fermin's answer):

    If it's to view css or js changes one way is to append _versionNo to the css/js file for each release. E.g.

    script_1.0.css script_1.1.css script_1.2.css etc.

    You can check out this link to see how it could work.



    我希望这些帮助。

    编辑。
    为了回应您的评论,很抱歉上述方法没有奏效。

    也许您可以尝试实现一种基于 websockets 的方法,类似于 Trello,在一定时间后,您要求用户更新他们的页面以接收系统的新更新或在他们的套接字连接超时时刷新?根据您的设置,您可能会发现本教程很有用: http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/

    关于javascript - 在生产服务器上刷新 angularjs 更改的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20684446/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com