response.setHeader("Cache-Control","no-cache"); 的意思?

 

response.setHeader("Cache-Control","no-cache"); 的意思?

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消息的值,那麼客戶機可以接收超出超時期指定值之內的響應消息。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章