简体   繁体   English

为什么没有根请求获取更新的index.html

[英]Why doesn't root request get the updated index.html

I am developing an angular app. 我正在开发一个有角度的应用程序。 Whenever I modify the index.html, a request to localhost:8000 doesn't get the updated index.html. 每当我修改index.html时,对localhost:8000的请求都不会获取更新的index.html。 Why is that? 这是为什么? I am using nodejs to host the server. 我正在使用nodejs托管服务器。 I have tripped over this too many times assuming the request would get the updated index.html, such as including a new script but nothing happens because the index.html isn't the updated one. 假设请求将获得更新的index.html(例如包括一个新脚本),但我跳了很多遍,但没有发生任何事情,因为index.html不是更新的脚本。 It is quite annoying every time I refresh I have to type index.html. 每次刷新时都非常烦人,我必须键入index.html。

app.config(['$locationProvider', '$routeProvider', function ($locationProvider, $routeProvider) {
    $locationProvider.html5Mode(true);

    $routeProvider.when('/', {
        redirectTo : '/login'
    }).when('/dashboard', {
        templateUrl: 'app/dashboard/dashboard.html',
        controller: 'dashboard'
    }).when('/login', {
        templateUrl: 'app/layout/login.html'
    }).when('/register', {
        templateUrl: 'app/layout/register.html'
    }).otherwise({
        redirectTo: '/'
    });
}]);

It's probably loading from the browser cache rather than the changed copy from the server. 它可能是从浏览器缓存中加载的,而不是从服务器中更改后的副本中加载的。

Try 尝试

location.reload(true)

to load it from the server. 从服务器加载它。

https://developer.mozilla.org/en-US/docs/Web/API/Location.reload https://developer.mozilla.org/zh-CN/docs/Web/API/Location.reload

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

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