1

While studying the caching strategies adopted by various search engine websites and Stackoverflow itself, I can't help but notice the subtle differences in the response headers:

Google Search

Cache-Control: private, max-age=0
Expires: -1

Yahoo Search

Cache-Control: private
Connection: Keep-Alive
Keep-Alive: timeout=60, max=100

Stackoverflow Search

Cache-Control: private

There must be some logical explanation behind the settings adopted. Can someone care to explain the differences so that everyone of us can learn and benefit?

4

1 に答える 1

1

RFC2616 HTTP / 1.1ヘッダーフィールド定義から、14.9.1キャッシュ可能とは

private
   Indicates that all or part of the response message is intended for a single
   user and MUST NOT be cached by a shared cache. This allows an origin server
   to state that the specified parts of the response are intended for only one
   user and are not a valid response for requests by other users. A private
   (non-shared) cache MAY cache the response.

max-age=0これは、最大0秒までキャッシュされる可能性があることを意味します。値ゼロは、キャッシュを実行しないことを意味します。

Expires=-1プレゼントがある場合は無視する必要がありmax-ageます。-1は無効な日付であり、過去の値(すでに期限切れであることを意味します)として解析する必要があります。

RFC2616 HTTP / 1.1ヘッダーフィールド定義から、14.21の有効期限:

Note: if a response includes a Cache-Control field with the max-age directive
      (see section 14.9.3), that directive overrides the Expires field

HTTP/1.1 clients and caches MUST treat other invalid date formats, especially
including the value "0", as in the past (i.e., "already expired").

およびは、持続的接続の設定を構成しConnection: Keep-Aliveます。HTTP / 1.1を使用するすべての接続は、特に指定されていない限り永続的ですが、これらのヘッダーは、ブラウザーのデフォルト(大幅に異なります)を使用する代わりに、実際のタイムアウト値を変更します。Keep-Alive: timeout=60, max=100

于 2012-05-02T05:30:18.357 に答える