为什么响应304没有Content-Type标头?

And*_*ren 9 http http-headers express

我一直在玩express.js试图返回简单的json对象,并注意到即使我明确设置了Content-Type标题,application/json它只在第一个响应时可见,当状态代码是200时.每个跟随304的响应都没有Content-Type标题.

我的代码示例:

app.get('/user', function (req, res) {
    res.set('Content-Type', 'application/json');

    res.send([
        { user: "john", email: "john@example.com"},
        { user: "marry", email: "marry@example.com"},
        { user: "dan", email: "dan@example.com"}
    ]);
});
Run Code Online (Sandbox Code Playgroud)

这是什么原因?

And*_*ert 8

304 Not Modified表示请求包含一个条件标头,要求服务器在资源已被修改时才响应资源的内容.

由于没有返回任何内容,因此Content-Type不会发送标头.这是推荐行为304 Not ModifiedHTTP应答.

我对express.js一无所知,但我会研究正在进行什么样的缓存.