羊皮紙論壇

羊皮紙論壇

分享讓知識傳播,閱讀讓心靈成長, 創作讓文化傳承,讓我們共同努力。
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
羊皮紙論壇目錄 / 程式設計 / 網頁/網站程式 / PHP /

控制網頁快取的方法

發表新主題
隨機主題
上個主題
下個主題
|
控制網頁快取的方法

Any valid HTTP headers can be put in these files. This provides another way to apply the Expires header, and it's a way to add the Cache-Control headers. The relevant Cache-Control headers are:
  • Cache-Control : max-age = [delta-seconds]
    Modifies the expiration mechanism, overriding the Expires header. Max-age implies Cache-Control : public.
  • Cache-Control : public
    Indicates that the object may be stored in a cache. This is the default.
  • Cache-Control : private
  • Cache-Control : private = [field-name]
    Indicates that the object (or specified field) must not be stored in a shared cache and is intended for a single user. It may be stored in a private cache.
  • Cache-Control : no-cache
  • Cache-Control : no-cache = [field-name]
    Indicates that the object (or specified field) may be cached, but may not be served to a client unless revalidated with the origin server.
  • Cache-Control : no-store
    Indicates that the item must not be stored in nonvolatile storage, and should be removed as soon as possible from volatile storage.
  • Cache-Control : no-transform
    Proxies may convert data from one storage system to another. This directive indicates that (most of) the response must not be transformed. (The RFC allows for transformation of some fields, even with this header present.)
  • Cache-Control : must-revalidate
  • Cache-Control : proxy-revalidate
    Forces the proxy to revalidate the page even if the client will accept a stale response. Read the RFC before using these headers, there are restrictions on their use.

Example:

<meta http-equiv="Cache-Control" content="max-age=3600">
<meta http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT">

Caveats and gotchas


  • HTTP/1.0 has minimal cache control and only understands the Pragma: no-cache header. Caches using HTTP/1.0 will ignore the Expires and Cache-Control headers.

    None of the Cache-Control directives ensure privacy or security of data. The directives "private" and "no-store" assist in privacy and security, but they are not intended to substitute for authentication and encryption.

    This article is not a substitute for the RFC. If your are implementing the Cache-Control headers, do read the RFC for a detailed description of what each header means and what the limits are.
  • 關鍵字 : Control, Cache, cache, headers, header, stored, private, field, Indicates, Expires, storage, revalidate, object, using, these, substitute, store, specified, security, response
0 0
2008-06-09T10:32:00+0000


  • 當您未登入羊皮紙時,可以利用臉書 Facebook 登入來發表迴響。若使用羊皮紙會員身份發表迴響則可獲得經驗值及虛擬金幣,用來參加羊皮紙推出的活動。
發表迴響
 
驗證字串

Facebook 粉絲專頁

QRCode 條碼 & APP 連結

說明
本頁網址

在相關服務標籤中,『掃描條碼,在行動裝置』或是『點擊連結按鈕,在本裝置』中開啟網頁或是 APP 相關操作。
QRCode