Jersey提供Response物件來讓我們簡單的可以清除Cache。
好好利用cache也是一個節省頻寬跟效能的好方法。
如果有很多方法都需要清Cache的話,就考慮使用Filter的寫法比較方便。
@GET
@Path("/{uid}")
@Produces(MediaType.APPLICATION_JSON)
public Response getUser(
@PathParam(value="uid") String uid){
//do sth
ResponseBuilder rb = Response.ok(respJSON.toString());
CacheControl cc = new CacheControl();
cc.setNoCache(true);
return rb.cacheControl(cc).build();
}
沒有留言:
張貼留言
留個話吧:)