Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are HTTP Response Entity Tags?

Tags:

rest

http

jax-rs

Specifically in JAX-RS (I'm not sure that is relevant) there are methods that allow you to add EntityTags to the response. What exactly are entity tags and what practical ways are they used?

like image 600
jconlin Avatar asked Mar 02 '10 15:03

jconlin


3 Answers

Entity Tags are a way of incorporating caching into the HTTP Protocol. When a server returns a response it can attach an ETagheader which gives a value which represents the state of the object returned in response to the client's request.

When the client makes subsequent requests for the same response it can send back the ETag in it's request using the If-None-Match header and the server can use this to determine whether it needs to send a new response (i.e. the state of the requested object has changed) or whether it can respond with a 304 Not Modified response which instructs the client to use its local cached copy.

This is most often used in RESTful APIs and applications where caching and object state are relevant.

See http://en.wikipedia.org/wiki/HTTP_ETag

like image 106
RobV Avatar answered Nov 10 '22 18:11

RobV


In addition to Julians reference: In general, entity tags enable client, server and intermediaries to agree on the specific representation (hence entity tag) of a resource.

The agreement is used for reducing network use (conditional retrieval) and concurrency control (conditional updates). The former works along the lines of "Send me the current representation of this resource if it is not the representation I already have" and the latter works along the lines of "Apply this change to that resource if it still has the state that I expect it to have").

The rest is explained in detail in the HTTp spec.

Jan

like image 29
Jan Algermissen Avatar answered Nov 10 '22 18:11

Jan Algermissen


See Section 3.11 of RFC 2616.

like image 2
Julian Reschke Avatar answered Nov 10 '22 18:11

Julian Reschke