为什么root请求不获取更新后的index.html ?

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

本文关键字:index html 更新 root 请求 获取 为什么      更新时间:2023-09-26

我正在开发一个angular应用程序。每当我修改index.html时,对localhost:8000的请求不会得到更新的index.html。为什么呢?我使用nodejs来托管服务器。我已经被这个问题绊倒太多次了,假设请求会得到更新的index.html,比如包含一个新脚本,但是什么也没有发生,因为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: '/'
    });
}]);

可能是从浏览器缓存中加载的,而不是从服务器上更改的副本。

location.reload(true)

从服务器加载。

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