黑族論壇

黑族論壇

黑族論壇目錄 / 程式設計 / 網頁/網站程式 / 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 登入來發表迴響。若使用黑族會員身份發表迴響則可獲得經驗值及虛擬金幣,用來參加黑族推出的活動。
發表迴響
驗證字串
留言