On May 16, 2008, at 3:49 PM, Arul Dhesiaseelan wrote:
>
> I would like to disable IE caching in my HTTP response produced by
> REST service.
>
> Is there a way to set the header params in the response? I would
> like to do something like this.
>
> response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); //
> disable IE caching
>
Yes. You can use the methods of javax.ws.rs.core.Response/
ResponseBuilder and javax.ws.rs.core.CacheControl. E.g.:
CacheControl c = new CacheControl();
c.setNoCache(true);
Response r = Response.ok(someEntity,
someMediaType).cacheControl(c).build();
There is also a ResponseBuilder.header(name, value) method if you want
to add a header manually.
Marc.
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.