如何爲expressjs中的非靜態文件響應設置最大年齡參數。如何設置非靜態文件響應的最大年齡
我的代碼:
app.get('/hello', function(req, res) {
res.set('Content-Type', 'text/plain');
res.set({'maxAge':5});
res.send("Hello Message from port: " + port);
res.status(200).end()
})
我嘗試這樣做:
res.set({'max-age':5});
而且這樣的:
res.set({'Cache-Control':'max-age=5'});
這是工作的罰款與res.SendFile(file,{maxAge: 5})
但與靜態文件的問題我只在第一個http響應af中看到了「最大年齡」服務器啓動。
所有後續的響應報頭顯示「最大年齡= 0」,即使文件送達新鮮的(狀態200)
如果您使用nginx的代理交接請求,最好在nginx的設置頭。 – num8er