
2008年9月27日
摘要: 廢話不多說,先看看我們最終達到的效果.? 源碼下載在文章最后。Style1:Style2:上面的tag cloud實現思想如下:1. Server端提供Tag的相關信息,包括TagName,Posts等,使用JSON格式傳輸數據??? 這個例子中,我使用Servlet,使用json-lib將Bean轉成JSON字符串。當然Tag的相關信息這里只是演示,真實環境中可能就需要從數據庫取出來再處理了。?...
閱讀全文
posted @
2008-09-28 16:10 jht 閱讀(3160) |
評論 (3) |
編輯 收藏
1. response.setHeader("Cache-Control","no-cache");
This is used to prevent the browser from caching your dynamic content generated by a JSP or Servlet.
You set this attribute in the HTTP header of the response object which would tell the browser not to cache this content. So everytime you request the page again, the browser would make a new request, instead of showing you a cached page.
2.使用服務器端控制AJAX頁面緩存:??? response.setHeader( "Pragma", "no-cache" );
??? response.addHeader( "Cache-Control", "must-revalidate" );
??? response.addHeader( "Cache-Control", "no-cache" );
??? response.addHeader( "Cache-Control", "no-store" );
??? response.setDateHeader("Expires", 0);
單純的使用 xmlhttp.setRequestHeader("Cache-Control","no-cache")無效。
3.Cache-Control頭域
Cache-Control指定請求和響應遵循的緩存機制。在請求消息或響應消息中設置Cache-Control并不會修改另一個消息處理過程中的緩存處理過程。請求時的緩存指令包括no-cache、no-store、max-age、max-stale、min-fresh、only-if-cached,響應消息中的指令包括public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age。各個消息中的指令含義如下:
Public指示響應可被任何緩存區緩存。
Private指示對于單個用戶的整個或部分響應消息,不能被共享緩存處理。這允許服務器僅僅描述當用戶的部分響應消息,此響應消息對于其他用戶的請求無效。
no-cache指示請求或響應消息不能緩存
no-store用于防止重要的信息被無意的發布。在請求消息中發送將使得請求和響應消息都不使用緩存。
max-age指示客戶機可以接收生存期不大于指定時間(以秒為單位)的響應。
min-fresh指示客戶機可以接收響應時間小于當前時間加上指定時間的響應。
max-stale指示客戶機可以接收超出超時期間的響應消息。如果指定max-stale消息的值,那么客戶機可以接收超出超時期指定值之內的響應消息。
Read more:
???
http://www.jiehoo.com/browser-cache-problem.htm?(作者:
Cherami?原載:
瀏覽器緩存)
???
再論怎么有效利用瀏覽器緩存之怎么避免瀏覽器緩存靜態文件???
HTTP協議header頭域- PetitPrince - 博客園
posted @
2008-09-27 10:23 jht 閱讀(16590) |
評論 (3) |
編輯 收藏