代码之家  ›  专栏  ›  技术社区  ›  jr. Aikon Mogwai

设置泽西岛允许缓存?

  •  3
  • jr. Aikon Mogwai  · 技术社区  · 15 年前

    我从jersey@get方法返回了以下内容。它工作正常,但始终包含无缓存头。我希望允许客户端缓存此数据,因为它很少更改。

    ResponseBuilder rb = Response.ok(c);
        CacheControl cc = new CacheControl();
        cc.setMaxAge(60);
        cc.setNoCache(false);
        return rb.cacheControl(cc).build();
    

    回答总是:

     Server Apache-Coyote/1.1
     Pragma No-cache
     Cache-Control  no-cache, no-transform, max-age=60
     Expires    Wed, 31 Dec 1969 19:00:00 EST
     Content-Type   application/xml
     Content-Length 291
     Date   Tue, 16 Feb 2010 01:54:02 GMT
    

    我在这里做错了吗?

    2 回复  |  直到 14 年前
        1
  •  5
  •   Donal Fellows    14 年前

    这是由于打开了基本身份验证。

    在上下文中指定此选项将更正以下问题:

    <Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
           disableProxyCaching="false" />
    

    希望这能帮到别人。

        2
  •  0
  •   marklai    15 年前

    你的代码看起来不错。

    你用的是哪个容器?确保缓存未被禁用。还要验证下游响应处理程序或筛选器没有设置no cache指令。