我尝试使用public
类(JAX-RS)设置javax.ws.rs.core.CacheControl
指令
例如:Cache-Control : public, max-age= 1000
但是这段代码确实创建了public
指令:
Response.ResponseBuilder rb = Response.ok(entity);
CacheControl cacheControl = new CacheControl();
cacheControl.setPrivate(false);
cacheControl.setMaxAge(1000);
rb.cacheControl(cacheControl);
return rb.build();
答案 0 :(得分:1)
通过cacheControl.setPrivate(false)
将private设置为false并不意味着它应该被缓存public
。还有一个no-cache
令牌。
由于CacheControl
没有设置public
令牌的方法,您需要手动执行此操作:
CacheControl cacheControl = CacheControl.valueOf("public, max-age=1000")