为什么“最后修改"?在Google Cloud Platform App Engine上不正确? [英] Why is the "last-modified" incorrect on Google Cloud Platform App Engine?

查看:77
本文介绍了为什么“最后修改"?在Google Cloud Platform App Engine上不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I deployed my web on Google Cloud Platform App Engine several times. Using the setting as follows:

app.yaml

runtime: nodejs10

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

Everything just worked fine when I tested it on the localhost. But when I deployed it to Google Cloud Platform. The response header always is showing last-modified: Tue, 01 Jan 1980 00:00:01 GMT. I have checked by [my-web].df.r.appspot.com to make sure that the problem is coming from Google Cloud Platform.

有人有主意吗?

更新2020-10-07
对于面临相同问题的任何人,请随时此处加入讨论.

Updated 2020-10-07
For anyone facing the same issue, please feel free to join the discussion here.

推荐答案

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

Apparently, this is behaviour by design as all timestamps are made zero on deploy by app-engine. see: https://issuetracker.google.com/issues/168399701

我自己使用express发送静态文件.因此,我通过不设置etag和最后修改的标头解决了该问题.例如:

I was sending the static files myself using express. So I solved it by not setting the etag and last-modified headers. For example:

app.use("/", express.static(root, { etag: false, lastModified: false }));

或者对于单个文件:

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

这篇关于为什么“最后修改"?在Google Cloud Platform App Engine上不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆