顯示具有 Web Cache 標籤的文章。 顯示所有文章
顯示具有 Web Cache 標籤的文章。 顯示所有文章

星期四, 3月 15, 2012

[Java] Jersey 清除 response cache

通常在IE瀏覽器常常會遇到亂Cache一通的問題,
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();

}

星期二, 3月 13, 2012

Web Cache Issue

簡單記綠一下看完一些Web Cache資料的心得,
方便以後快速學習。

使用Cache的理由

To reduce latency
To reduce network traffic

Web Caches的種類
Browser Caches:
Proxy Caches:
Gateway Caches: 如Content delivery networks (CDNs)

在你的網頁控制Caches


在網頁的Header加上HTML Meta Tags
PRAGMA HTTP HEADERS:
<meta http-equiv="Pragma" content="no-cache">

其他你感興趣的文章

Related Posts with Thumbnails