【发布时间】:2015-10-06 18:16:29
【问题描述】:
我正在使用 express 4 提供图像流:
app.get('/v1/images/:Uid/', function(req, res) {
var gcsbucket = gcs.bucket('bucket'),
remoteReadStream = gcsbucket.file(req.params.Uid+'.jpg').createReadStream();
remoteReadStream.pipe(res);
});
(图片存储在谷歌云存储中)
我正在尝试找到一种方法来告诉浏览器缓存我正在提供的图像。 我尝试添加:
res.set('Cache-Control', 'public, max-age=31557600');
但是当我在http://server/v1/images/1234 访问 API 时,这并没有改变任何东西,它总是重新加载图像。
在使用流服务器端时,告诉浏览器缓存响应的正确方法是什么?
【问题讨论】:
标签: node.js express stream google-cloud-storage