I'm building a node.js app which - reguarly, once a day - fetches data from some external web server (using "request" package).
I want to avoid fetching same data twice, so I keep track of each resource ETag when first downloading (200 status code).
Then, when fetching again (next day) that resource I add an If-None-Match header with the saved etag in the request.
Since I suspect to sometime receive a 200 status code (instead of expected 304) from the remote web server even if a resource contents is not modified, I ask if I should expect the resource ETag to be returned in a 304 response (and how to get it in the request response...), to try to debug this issue.
An ETag (entity tag) is an HTTP header that is used to validate that the client (such as a mobile device) has the most recent version of a record. When a GET request is made, the ETag is returned as a response header. The ETag also allows the client to make conditional requests.
The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource.
The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.
Please have a look at appropriate RFC 2616.
The response MUST include the following header fields: (...)
- ETag and/or Content-Location, if the header would have been sent in a 200 response to the same request
So if ETag header is returned with 200 OK status code it also must be included in 304 Not Modified response.
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