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.使用服務(wù)器端控制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指定請求和響應(yīng)遵循的緩存機(jī)制。在請求消息或響應(yīng)消息中設(shè)置Cache-Control并不會修改另一個消息處理過程中的緩存處理過程。請求時的緩存指令包括no-cache、no-store、max-age、max-stale、min-fresh、only-if-cached,響應(yīng)消息中的指令包括public、private、no-cache、no-store、no-transform、must-revalidate、proxy-revalidate、max-age。各個消息中的指令含義如下:
Public指示響應(yīng)可被任何緩存區(qū)緩存。
Private指示對于單個用戶的整個或部分響應(yīng)消息,不能被共享緩存處理。這允許服務(wù)器僅僅描述當(dāng)用戶的部分響應(yīng)消息,此響應(yīng)消息對于其他用戶的請求無效。
no-cache指示請求或響應(yīng)消息不能緩存
no-store用于防止重要的信息被無意的發(fā)布。在請求消息中發(fā)送將使得請求和響應(yīng)消息都不使用緩存。
max-age指示客戶機(jī)可以接收生存期不大于指定時間(以秒為單位)的響應(yīng)。
min-fresh指示客戶機(jī)可以接收響應(yīng)時間小于當(dāng)前時間加上指定時間的響應(yīng)。
max-stale指示客戶機(jī)可以接收超出超時期間的響應(yīng)消息。如果指定max-stale消息的值,那么客戶機(jī)可以接收超出超時期指定值之內(nèi)的響應(yīng)消息。
Read more:
???http://www.jiehoo.com/browser-cache-problem.htm?(作者: Cherami?原載: 瀏覽器緩存)
???再論怎么有效利用瀏覽器緩存之怎么避免瀏覽器緩存靜態(tài)文件
???HTTP協(xié)議header頭域- PetitPrince - 博客園