Agent96
Agent96

Reputation: 475

ETag with Accept-Language

I have a web service which puts an ETag on to each response so future calls can make use of the HTTP 304 (Not Modified) status. The ETag I generate really just a Base64 encoding of the query type along with the timestamp.

The problem I have is if the browser requests the same resource with a difference Accept-Language. The browser currently sends the same If-None-Match header, so the response is a 304, even thought the actual resource would have come back in a different language. So I thought the way to do this was to add a Vary Header, to specify to the client that the response varys with Accept & Accept-Language, as shown below.

Vary:Accept, Accept-Language

However my browser (Chrome) uses the same ETag regardless of the accept-language. What is the correct convention to use here?

Thanks

Upvotes: 3

Views: 367

Answers (1)

Dmitry T.
Dmitry T.

Reputation: 703

E-Tag identifies the response contents. So better use a response body hash for E-Tag construction. At least you can use hash of a query and a language concatenated.

Upvotes: 2

Related Questions