node.js - etag 中的 W/in 从哪里出现?

标签 node.js http nginx http-headers etag

当我没有添加 W/时,我对它在 etag 中的显示方式感到困惑。 我正在使用 Node.js http 服务器模块并将 Nginx 作为反向代理。我让浏览器看到由 Node.js 服务器生成的 Etag,但带有 W/标记。

有人可以解释一下 W/的来源吗?浏览器是否根据确定它是弱 etag 来插入它?我希望浏览器在我发送时得到它。没有 W/前缀。

这是在浏览器中看到的 Etag header 。

etag: W/"asv1534746804282-d62serveav"

当尝试与 if-none-match 进行比较时,我必须去掉 W/。 另外,对于 304 状态响应,我是否必须再次发送 Etag?

编辑:我自己添加了 W/以便 Nginx 保持不变。我希望我的假设是正确的。看来是。

最佳答案

如果您要求 nginx 动态压缩您的内容,它会将您的 ETag 转换为弱 ETag。这是 the specification 所要求的,因为强 ETag 只能用于字节对字节相同的内容。

A validator is weak if it is shared by two or more representations of a given resource at the same time, unless those representations have identical representation data. For example, if the origin server sends the same validator for a representation with a gzip content coding applied as it does for a representation with no content coding, then that validator is weak.

关于node.js - etag 中的 W/in 从哪里出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51973120/

相关文章:

javascript - Facebook 更改页面 URL 但实际上并未更改页面

php - Nginx:413 请求实体太大

docker - 如何使用多个 docker-compose.yml 文件配置 nginx?

macos - 在 macOS 上意外使用了端口 80,结果为 "It works"

javascript - 在 node.js 中 `module` 总是一个对象吗?

javascript - Angular 4200 端口显示带 html 的数据,但 Nodejs 8080 端口显示不带 html 的 json 数据

objective-c - http请求的可接受速率

java - AWS Elastic BeansTalk Nginx 超时 504 错误网关 - Java Servlet AsyncContext

mongodb - 每五分钟安排一次 Node.js 作业

node.js - 如何快速执行终端命令?