7

I am confused by how the W/ appears in the etag when I have not added it. I am using Node.js http server module and have a Nginx as reverse proxy. I am getting the browser see the Etag generated by the Node.js server but with a W/ tagged to it.

Can someone explain where that W/ comes from? Does the browser insert that based upon its determination that it is a weak etag? I want the browser to get it as I sent it. Without the W/ prefix.

Here is the Etag header as seen in the browser.

etag: W/"asv1534746804282-d62serveav"

When trying to compare with if-none-match, I have to strip the W/. Also, with the 304 status response, do I again have to send the Etag?

EDIT: I added the W/ myself so that Nginx leaves it unmodified. I hope my assumption is correct. It appears to be.

Sunny
  • 9,245
  • 10
  • 49
  • 79
  • I added an answer explaining where I think this is coming from. Could you expand on how this is actually causing you a problem? nginx supports matching weak ETags in `If-None-Match` as of [version 1.7.3](https://github.com/nginx/nginx/compare/release-1.7.2...release-1.7.3). – Kevin Christopher Henry Aug 22 '18 at 21:43

1 Answers1

11

If you ask nginx to dynamically gzip your content it will convert your ETags into weak ones. This is required by the specification, since a strong ETag can only be used for content that is byte-for-byte identical.

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.

Community
  • 1
  • 1
Kevin Christopher Henry
  • 46,175
  • 7
  • 116
  • 102