lloyd / connect-etagify

etagify is connect middleware to add ETag headers to cachable but non-static content.
49 stars 6 forks source link

Vary logic appears to be incorrect. #2

Open sporkmonger opened 12 years ago

sporkmonger commented 12 years ago

I'm pretty sure you're supposed to build the lookup key from the request headers specified in the Vary response header. So if the response indicated Vary: Accept-Encoding, Accept-Language you wouldn't actually store [ 'Accept-Encoding', 'Accept-Language' ] in your data structure, I think you're supposed to store the tuple of [req.path, "gzip,deflate,sdch", "en-US,en;q=0.8"] (assuming Chrome user agent used in request). And you probably need to handle Vary: * specially.

Ideally though, as mentioned in issue #1, you'd just buffer the content and calculate the ETag directly, in which case the Vary header should be irrelevant since you're not actually acting as a cache. (i.e., if issue #1 is resolved by calculating ETag every single time, this issue becomes invalid.)