users@jersey.java.net

Re: [Jersey] disabling IE cache on the HTTP response

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 May 2008 10:27:42 +0200

Marc Hadley wrote:
> 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.
>

Perhaps we should add expires(Date date) or header(String name, Date date) ?

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109