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.
An entity tag (ETag) is an HTTP header used for Web cache validation and conditional request from browsers to resources. The value of an ETag is an identifier that represents a specific version of the resource. Additionally, ETags help prevents simultaneous updates of a resource from overwriting each other.
Etags are just a Http request header just like any other from curls point of view. So you can just use: curl -v -H 'If-None-Match: 123456789' http:your.server.com/your/path/here.
Etag Working Style in StepsThe server generates an Etag value as a response header value. Requestor takes a 200 (Ok) status code for the resource and uses the Etag value for the If-None-Match request header. A requestor requests the same resource after a time.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With