简体   繁体   中英

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. Why is that? I am using nodejs to host the server. 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. It is quite annoying every time I refresh I have to type 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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