dev@jersey.java.net

Cache-Control ignored when LoggingFilter is not used.

From: Theresa Jahelka <terry.jahelka_at_issinc.com>
Date: Wed, 29 Aug 2012 13:53:33 +0000

Hello,

I'm new to using Jersey and I'm having an issue with webstart and the requests being cached. I've set the cache-control to no-cache and this works but only when I have the client.addFilter(new LoggingFilter()). If I comment out the addFilter() line, the data is once again cached. While the LoggingFilter is great for development and test environments I do not want to run this filter in our production environment. Code snippet is below. What have I done wrong?


    @Test
    public void testGetMetadataQuerySpecJson() {
        Client client = Client.create();
        client.addFilter(new LoggingFilter());
        WebResource resource = client.resource("http://localhost:8080/services-web/cdf/metadata");
        client.addFilter(new HTTPBasicAuthFilter("cdf", "cdf"));
        ClientResponse response = resource.header("Cache-Control", "no-cache")
                .get(ClientResponse.class);
        Assert.assertEquals(200, response.getStatus());
        Assert.assertEquals(APPLICATION_JSON_TYPE, response.getType());
    }


Jul 23, 2012 2:21:38 PM com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer <init>
INFO: Creating Grizzly2 Web Container configured at the base URI http://localhost:9998/
Jul 23, 2012 2:21:38 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [localhost:9998]
Jul 23, 2012 2:21:38 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
Jul 23, 2012 2:21:38 PM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client out-bound request
1 > GET http://localhost:8080/services-web/cdf/metadata
1 > Cache-Control: no-cache
1 > Authorization: Basic Y2RmOmNkZg==

Jul 23, 2012 2:21:38 PM com.sun.jersey.api.client.filter.LoggingFilter log
INFO: 1 * Client in-bound response
1 < 200
1 < Expires: Wed, 31 Dec 1969 17:00:00 MST
1 < X-Jersey-Trace-002: accept right hand path java.util.regex.Matcher[pattern=/cdf/metadata(/.*)? region=0,13 lastmatch=/cdf/metadata]: "/cdf/metadata" -> "/cdf/metadata" : ""
1 < X-Jersey-Trace-003: accept resource: "cdf/metadata" -> @Path("/cdf/metadata") com.issinc.cdf.rest.MetadataResource_at_12b3cc4<mailto:com.issinc.cdf.rest.MetadataResource_at_12b3cc4>
1 < X-Jersey-Trace-000: accept root resource classes: "/cdf/metadata"
1 < X-Jersey-Trace-001: match path "/cdf/metadata" -> "/application\.wadl(/.*)?", "/cdf/metadata(/.*)?", "/cdf/info(/.*)?", "/cdf/data(/.*)?", "/cdf/svc(/.*)?"
1 < Set-Cookie: JSESSIONID=9F58750A7DE9916D1E285F8C50DE6B99; Path=/services-web/; HttpOnly
1 < X-Jersey-Trace-006: matched resource method: public javax.ws.rs.core.Response com.issinc.cdf.rest.MetadataResource.getMetadata(javax.ws.rs.core.SecurityContext,javax.servlet.http.HttpServletRequest,javax.ws.rs.core.UriInfo,com.issinc.cdf.rest.Format,com.issinc.cdf.rest.UriFormat,boolean,boolean,java.lang.String) throws java.lang.Exception
1 < X-Jersey-Trace-007: matched message body writer: java.lang.String_at_a0de8621<mailto:java.lang.String_at_a0de8621>, "application/json" -> com.sun.jersey.core.impl.provider.entity.StringProvider_at_e5707f<mailto:com.sun.jersey.core.impl.provider.entity.StringProvider_at_e5707f>
1 < Server: Apache-Coyote/1.1
1 < X-Jersey-Trace-004: match path "" -> "/(.*)(/)?", ""
1 < Cache-Control: private
1 < X-Jersey-Trace-005: accept resource methods: "cdf/metadata", GET -> com.issinc.cdf.rest.MetadataResource_at_12b3cc4<mailto:com.issinc.cdf.rest.MetadataResource_at_12b3cc4>
1 < Date: Mon, 23 Jul 2012 20:21:38 GMT
1 < Transfer-Encoding: chunked
1 < Content-Type: application/json
1 <
{"result":{"informationModels":[{"Security":{"uri":"http://localhost:8080/services-web/cdf/metadata/Security"}}]}}

Jul 23, 2012 2:21:38 PM com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer stop
INFO: Stopping the Grizzly2 Web Container...
Jul 23, 2012 2:21:38 PM org.glassfish.grizzly.http.server.NetworkListener stop
INFO: Stopped listener bound to [localhost:9998]