如何在Jersey响应中设置缓存控制头

时间:2014-02-26 12:18:00

标签: java rest http-headers jersey

我想在Jersy响应对象中设置缓存控制头。

我尝试过类似的但是没有用。

缓存控件仍然没有响应缓存。

 CacheControl cc = new CacheControl();
        cc.setNoStore(true);
        cc.setNoCache(true);
        cc.setMustRevalidate(true);

   return Response.ok(pdf).cacheControl(cc).header("Pragma", "no-cache").build()

Resposne仍显示缓存控制

Cache-Control   no-cache

有人可以告诉我们如何做到这一点。

1 个答案:

答案 0 :(得分:2)

我想它应该是这样的:

CacheControl cc = new CacheControl();
cc.setNoCache(true);
cc.setNoStore(true);
cc.setMustRevalidate(true);
return Response.ok(pdf).cacheControl(cc).build();
相关问题