问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/51973120/where-does-the-w-in-an-etag-appear-from