在Express Node.js中禁用etag标头 [英] Disable etag Header in Express Node.js
问题描述
我们需要从Node.js Express应用程序中的所有HTTP响应中删除 etag
标头.我们有一个用Express编写的Web服务API,当我们发送etag时,客户端会看到意外的结果,而客户端会发回 if-none-match
标头.
我们尝试了 app.disable('etag')
和 res.removeHeader('etag')
,但均无效;该应用会发送标头,无论如何.
在所有响应中还有其他禁用此标头的方法吗?
app.disable('etag')
现在应该可以正常工作了,已经合并了一个拉取请求来处理此问题:>
https://github.com/visionmedia/express/commit/610e172fcf9306bd5812bb2bae8904c23e0e8043 /p>
更新:正如Bigood在评论中指出的,新的处理方式如下:
app.set('etag',false);//关
版本3.9.0中发生了更改: https://github.com/strongloop/express/releases/tag/3.9.0
有关设置etag的更多选项,请在此处查看4.x文档: http://expressjs.com/4x/api.html#app.set
We have a need to remove the etag
header from all HTTP responses in our Node.js Express application. We have a web services API written in Express where unexpected results are seen at the client when we send etags and the client sends back the if-none-match
header.
We've tried app.disable('etag')
and res.removeHeader('etag')
, but neither work; the app sends the header regardless.
Is there any other means of disabling this header in all responses?
app.disable('etag')
should work now, there has been a pull request merged to deal with this:
https://github.com/visionmedia/express/commit/610e172fcf9306bd5812bb2bae8904c23e0e8043
UPDATE: as Bigood pointed out in the comments the new way of doing things is the following
app.set('etag', false); // turn off
Change occured with version 3.9.0: https://github.com/strongloop/express/releases/tag/3.9.0
For more options on setting the etag check the 4.x docs here: http://expressjs.com/4x/api.html#app.set
这篇关于在Express Node.js中禁用etag标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!