为什么 Google Cloud Platform App Engine 上的“上次修改时间”不正确?

Ben*_*hen 6 google-app-engine google-cloud-platform

我在 Google Cloud Platform App Engine 上多次部署了我的网络。使用设置如下:

应用程序.yaml

runtime: nodejs10
Run Code Online (Sandbox Code Playgroud)

当我在本地主机上测试它时,一切都工作正常。但是当我将它部署到谷歌云平台时。响应标头始终显示last-modified: Tue, 01 Jan 1980 00:00:01 GMT。我已检查[my-web].df.r.appspot.com以确保问题来自 Google Cloud Platform。

有人有想法吗?

更新于2020-10-07
对于遇到同样问题的人,请随时加入这里的讨论。

Wou*_*ter 5

显然,这是设计的行为,因为应用程序引擎在部署时将所有时间戳设置为零。请参阅: https: //issuetracker.google.com/issues/168399701

我自己使用快递发送静态文件。所以我通过不设置 etag 和最后修改的标头解决了这个问题。例如:

app.use("/", express.static(root, { etag: false, lastModified: false }));
Run Code Online (Sandbox Code Playgroud)

或者对于单个文件:

app.get("/*", async (req, res) => {
  return res.sendFile("index.html", { root, lastModified: false, etag: false });
});
Run Code Online (Sandbox Code Playgroud)