On Jun 4, 2009, at 3:25 PM, glassfish_at_javadesktop.org wrote:
> Hello,
> I'm developing a RESTful service using GlassFish EJB3 and Jersey.
> My client application is WPF application written in C#.
>
> I would like to be able to have my client applcation "be updated"
> when something changes on the service side.
> Base on that I'm caching all the entities return from the service on
> the client side I can pretty easy find which entities are new and
> deleted by polling on the service resources every so often.
> The problem is how to know when they are updated.
> I though of using Etags which help me notice that an entities has
> change, maybe even reduce network usage.
>
> 1. Is that a good idea?
Yes, you can also use last modified dates as well.
>
> 2. How can I generate ETags with Jersey in the mode no-code-needed
> way?
>
There is currently no support for automatic generation of etags and
mechanism to return a 2xx or a 304 depending on etag(s) sent by the
client.
So you will have to write your own code to generate the etag and use
the Request.evaluatePreconditions:
https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/Request.html
I think it should be possible to support a Jersey container request
filter to calculate the etag from the bytes of the serialized response
entity. This will save bandwidth but will not save on compute.
Paul.