users@jersey.java.net

[Jersey] Should I include media type in my ETag?

From: Jason Erickson <jason_at_jasonerickson.com>
Date: Tue, 1 Nov 2011 17:06:56 -0700

When adding an ETag to an HTTP response, should I include the media type? Of course, I understand that the ETag is opaque, but here is an example:

Say I have a client that requests a Person in application/json. I look it up and create my ETag and send back the JSON representation of the person
Now the same client makes another request for the same person (which has not been modified) at the same URI but wants it in application/xml.
Clearly it is incorrect to simply return a 304, but my question is, in the second request, would I expect the ETags to match but no cache based on the Accept header (or the content header). Also, is it even possible that the cache will have two representations from the same URI, or would you always get have an invalid cache every time your Content-Type switched?