キャッシュ指令

Cache-Control: ヘッダー (HTTP)

[34] Cache-Control: ヘッダーは、 キャッシュにおける要求応答の処理方法を指定するものです。

仕様書

意味

[20] Cache-Control: ヘッダーは、 キャッシュに対する指令 (キャッシュ指令 (cache directive) ) を指定するものです >>19

[37] ただし、キャッシュを有しない中間器にも適用されるキャッシュ指令もあります。

[21] このヘッダー要求でも応答でも利用できます。 このヘッダーに指定する指令は、要求で用いるもの、 応答で用いるもの、どちらでも用いるものがあります。 しかしいずれにせよ指令は一方向的なものですから、 要求で指定されていたとしても、応答でも同じ指令が適用されることを意味しません >>19

[45] 同じキャッシュ指令でも要求応答引数の構文が異なることがあります。

構文

[29] Cache-Control: ヘッダーの値は、 1つ以上のキャッシュ指令リスト (#) です >>19

  1. キャッシュ指令
  2. *
    1. OWS
    2. ,
    3. OWS
    4. キャッシュ指令

[25] キャッシュ指令は、その種類を識別する字句と、 引数とで構成されます。 >>19

[26] 種類を表す字句は、大文字・小文字不区別です >>19

[27] 引数は省略できます。指定される場合は = の後に字句または引用文字列を記述します。 受信者は、 RFC 7234 で規定されている指令についてはどちらの構文も受け付けるべき (ought to) で、 それ以外についてはどちらも受け付けなければなりません>>19

[28] なぜすべてについて MUST にしないのか謎です。
  1. 字句
  2. ?
    1. =
    2. |
      1. 字句
      2. 引用文字列
[31] = の前後に BWS は認められていないようです。

[32] 引数を指定するかどうかは、指令ごとに規定されています。 指令ごとに字句引用文字列のどちらの構文が好ましいか規定されていることもあります。

[33] RFC 7234 で規定されているキャッシュ指令については、 明記されていない限り引数は定義されず、認められない >>19 とされています。
[51] 新しいキャッシュ指令を規定する際には、引数が必須である場合に省略されると何を意味するかを規定することを検討するよう求められています >>49。 しかし当の RFC 7234 自身はそのような規定を有していません。

文脈

[30] このヘッダーは複数指定できます。

[17] 304 の項も参照。

[60] EventSource のための fetch では、 利用者エージェント要求Cache-Control: no-cache を指定するべきです >>59

処理

[22] キャッシュは、 RFC 7234キャッシュ指令の要件に従わなければなりません >>19

[23] HTTP/1.0 キャッシュの中には、 Cache-Control: を実装していないものもあります >>19

[24] は、キャッシュを有しているかどうかに関わらず、 キャッシュ指令をそのまま転送しなければなりません >>19

[41] キャッシュは、未知のキャッシュ指令を無視しなければなりません >>40

[18] 同じ指令が複数ある場合について一般的な規定はありません。 一部のキャッシュ指令では規定があります (新鮮寿命を参照)。

[50] 新たなキャッシュ指令を定義する時は複数回指定された時の意味を定義することを検討するよう求められています >>49 が、義務付けられているわけではなく、また RFC 7234 自身が規定するキャッシュ指令の多くでも定義はされていません。

[43]キャッシュ指令の処理モデルについては、それぞれの項を参照。

[42] なお、キャッシュ指令の中には no-transform のようにキャッシュを持たない中間器にも適用されるものもあります。 また、AppCache や独自のキャッシュシステムなど HTTPキャッシュ以外の仕組みでも Cache-Control: の一部のキャッシュ指令に従うものがあります。

[61] EventSource のための fetch では、 応答キャッシュヘッダーは無視するべきで、 キャッシュを使うべきではありません >>59

キャッシュ指令

[35] Cache-Control: における個々の指定のことを、 キャッシュ指令 (cache directive) といいます。

[36] 要求における Cache-Control: ヘッダーキャッシュ指令のことは要求指令 (request directive) 応答における Cache-Control: ヘッダーキャッシュ指令のことは応答指令 (response directive) と呼ばれています。

cache-directive要求応答出典
access-restrictedI-D
auth-cacheI-D
cache-groupI-D
contextI-D
discard-contextI-D
x-gzip-ok
imRFC 3229
immutable
inv-maxageI-D
max-ageRFC 2068, RFC 2616
max-staleRFC 2068, RFC 2616
min-freshRFC 2068, RFC 2616
must-revalidateRFC 2068, RFC 2616
no-cacheRFC 2068, RFC 2616
no-storeRFC 2068, RFC 2616
no-transformRFC 2068 (応答), RFC 2616 (要求応答)
only-if-cachedRFC 2068, RFC 2616
post-check
pre-check
privateRFC 2068, RFC 2616
proxy-public
publicRFC 2068, RFC 2616
proxy-revalidateRFC 2068, RFC 2616
retainRFC 3229
s-maxageRFC 2616
stale-if-errorRFC 5861
stale-while-revalidateRFC 5861
user-public
x-wms-event-subscription
x-wms-proxy-split
x-wms-content-size
x-wms-stream-type

[44] RFC 7234 は「community」という架空のキャッシュ指令の例を示しています >>40

[58] SSDP では max-age のみ指定しなければなりません。 それ以外が指定されても無視しなければなりません。 >>57

[47] IANA登録簿 (>>46) は RFC 7234 で新設されました。

[48] しかし登録されていないキャッシュ指令の利用は特に禁止されていません。

[52] キャッシュ指令の一覧は >>53JSON ファイルにも含まれています。

歴史

[4] RFC 2068・2616 (HTTP/1.1) 14.9 Cache-Control

The Cache-Control general-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. The directives specify behavior intended to prevent caches from adversely interfering with the request or response. These directives typically override the default caching algorithms. Cache directives are unidirectional in that the presence of a directive in a request does not imply that the same directive should is to be given in the response.

Cache-control 一般頭欄は全てのキャッシュ機構が要求・応答の鎖に沿って 従わなければならない指示を指定するのに使います。 指示はキャッシュが要求や応答の不利な妨害となるのを防ぐのを 目的として振舞いを指定します。これらの指示は典型的には既定の キャッシュ算法を上書きします。キャッシュ指示は一方向性のものであって、 要求に指示が使われていることは同じ指示が応答にも使われることを 暗示するものではありません。

Note that HTTP/1.0 caches may not implement Cache-Control and may might only implement Pragma: no-cache (see section 14.32).

なお、 HTTP/1.0 キャッシュは Cache-Control を実装しておらず、 Pragma: no-cache だけを実装しているかもしれませぬ。

Cache directives must MUST be passed through by a proxy or gateway application, regardless of their significance to that application, since the directives may might be applicable to all recipients along the request/response chain. It is not possible to specify a cache- directive for a specific cache.

キャッシュ指示は串や関門応用を通り抜けなければなりません。 当該応用に対する意義の如何に関わらずです。なぜなら指示は 要求・応答の鎖にある全ての受信者に対して適用され得るからです。 特定キャッシュに対して cache-directive を指定することは不可能です。

  • Cache-Control = "Cache-Control" ":" 1#cache-directive
  • cache-directive = cache-request-directive | cache-response-directive
          cache-request-directive =
                            "no-cache" [ "=" <"> 1#field-name <"> ]
                          | "no-store"
                          | "max-age" "=" delta-seconds
                          | "max-stale" [ "=" delta-seconds ]
                          | "min-fresh" "=" delta-seconds
                          | "only-if-cached"
                          | cache-extension
    cache-request-directive =
           "no-cache"                          ; Section 14.9.1
         | "no-store"                          ; Section 14.9.2
         | "max-age" "=" delta-seconds         ; Section 14.9.3, 14.9.4
         | "max-stale" [ "=" delta-seconds ]   ; Section 14.9.3
         | "min-fresh" "=" delta-seconds       ; Section 14.9.3
         | "no-transform"                      ; Section 14.9.5
         | "only-if-cached"                    ; Section 14.9.4
         | cache-extension                     ; Section 14.9.6
          cache-response-directive =
                            "public"
                          | "private" [ "=" <"> 1#field-name <"> ]
                          | "no-cache" [ "=" <"> 1#field-name <"> ]
                          | "no-store"
                          | "no-transform"
                          | "must-revalidate"
                          | "proxy-revalidate"
                          | "max-age" "=" delta-seconds
                          | cache-extension
     cache-response-directive =
           "public"                               ; Section 14.9.1
         | "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
         | "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
         | "no-store"                             ; Section 14.9.2
         | "no-transform"                         ; Section 14.9.5
         | "must-revalidate"                      ; Section 14.9.4
         | "proxy-revalidate"                     ; Section 14.9.4
         | "max-age" "=" delta-seconds            ; Section 14.9.3
         | "s-maxage" "=" delta-seconds           ; Section 14.9.3
         | cache-extension                        ; Section 14.9.6
  • cache-extension = token [ "=" ( token | quoted-string ) ]

When a directive appears without any 1#field-name parameter, the directive applies to the entire request or response. When such a directive appears with a 1#field-name parameter, it applies only to the named field or fields, and not to the rest of the request or response. This mechanism supports extensibility; implementations of future versions of the HTTP protocol may might apply these directives to header fields not defined in HTTP/1.1.

指示が 1#field-name パラメーターなしに現れる時、その指示は 要求又は応答全体に適用されます。その様な指示が 1#field-name パラメーターつきで現れる時、これはその名前の欄(達)にのみ 適用され、要求や応答の残りには適用されません。この機構は拡張性をもちます。 将来の版の HTTP プロトコルの実装はこれらの指示を HTTP/1.1 で定義されていない頭欄に適用するかもしれません。

The cache-control directives can be broken down into these general categories:

cache-control 指示は次の一般分類に分けることが出来ます。

  • o - Restrictions on what is cacheable; these may only be imposed by the origin server.
  • o - Restrictions on what may be stored by a cache; these may be imposed by either the origin server or the user agent.
  • o - Modifications of the basic expiration mechanism; these may be imposed by either the origin server or the user agent.
  • o - Controls over cache revalidation and reload; these may only be imposed by a user agent.
  • o - Control over transformation of entities.
  • o - Extensions to the caching system.
  • 何がキャッシュ可能かの制限。これは源サーバーのみ課せる。
  • 何がキャッシュに蓄積可能かの制限。これは源サーバーと利用者代理者の 両者が課せる。
  • 基本期限機構の編集。これは源サーバーと利用者代理者の 両者が課せる。
  • キャッシュの再検証と再読み込みの制御。これは利用者代理者のみ課せる。
  • 実体の転送に係る制御
  • キャッシュ系統の拡張

14.9.1 What is Cacheable 何がキャッシュ可能か

By default, a response is cacheable if the requirements of the request method, request header fields, and the response status indicate that it is cacheable. Section 13.4 summarizes these defaults for cacheability. The following Cache-Control response directives allow an origin server to override the default cacheability of a response:

既定では、応答はその要求 method, 要求頭欄及び応用状態がキャッシュ可能であると示していればキャッシュ可能です。 13.4節がキャッシュ可能性の既定をまとめています。 次の Cache-Control 応答指示によって、 応答の既定のキャッシュ可能性を起源サーバーが上書きすることができます。

public
Indicates that the response is cachable MAY be cached by any cache, even if it would normally be non-cacheable or cacheable only within a non-shared cache. (See also Authorization, section 14.8, for additional details.)

その応答は、通常ならキャッシュ可能でないか又は非共有キャッシュ中でのみキャッシュ可能なキャッシュを含めてどんなキャッシュでもキャッシュして構いません。 (追加の詳細については14.8節の Authorization をご覧下さい。)

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 MAY cache the response.

応答メッセージの全部又は一部が単独の利用者向けのものであって、 共有キャッシュはキャッシュしてはならないことを示します。 これによって起源サーバーは、応答の特定の部分が唯一の利用者向けのものであって他の利用者による要求に対する妥当な応答ではないと表明できます。 私的 (非共有) キャッシュは応答をキャッシュしても構いません

Note: This usage of the word private only controls where the response may be cached, and cannot ensure the privacy of the message content.

注意 : 単語 private のこの用法は応答をキャッシュしても良いかを制御するだけであって、 メッセージ内容のプライバシーを保護することは出来ません。

no-cache
Indicates that all or part of the response message MUST NOT be cached anywhere. If the no-cache directive does not specify a field-name, then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent caching even by caches that have been configured to return stale responses to client requests.

;応答メッセージの全部又は一部がどこにおいてもキャッシュしてはならないことを示します。 no-cache 指令が field-name を指定していなければ、キャッシュは起源サーバーの再検証で成功を得なければ後続の要求を満足するためにこの応答を使ってはなりません この指令により、起源サーバーは、 クライアントの要求に対して腐った応答を返すように設定されているキャッシュでさえキャッシュすることを防ぐことができます。

If the no-cache directive does specify one or more field-names, then a cache MAY use the response to satisfy a subsequent request, subject to any other restrictions on caching. However, the specified field-name(s) MUST NOT be sent in the response to a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent the re-use of certain header fields in a response, while still allowing caching of the rest of the response.

no-cache 指令が1つ以上の field-name を指定していれば、キャッシュは、キャッシュに関する他の制約の対象である 後続の要求を満足するのにこの応答を使っても構いません。 しかし、指定された field-name は、起源サーバーによる再検証で成功を得ない限り後続の要求に対する応答では送ってはなりません。 これによって、起源サーバーは、応答中の特定の頭欄が再利用されることを防ぎつつも、 応答の残りをキャッシュすることを認めることが出来ます。

Note: Most HTTP/1.0 caches will not recognize or obey this directive.

注意 : ほとんどの HTTP/1.0 キャッシュはこの指令を認識も従いもしません。

14.9.2 What May be Stored by Caches キャッシュは何を蓄積してもよいか

no-store 参照。

14.9.3 Modifications of the Basic Expiration Mechanism 基本満期機構の修正

The expiration time of an entity may MAY be specified by the origin server using the Expires header (see section 14.21). Alternatively, it may MAY be specified using the max-age directive in a response. When the max-age cache-control directive is present in a cached response, the response is stale if its current age is greater than the age value given (in seconds) at the time of a new request for that resource. The max-age directive on a response implies that the response is cacheable (i.e., "public") unless some other, more restrictive cache directive is also present.

If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 (or later) cache than to an HTTP/1.0 cache. This may might be useful if certain HTTP/1.0 caches improperly calculate ages or expiration times, perhaps due to desynchronized clocks.

Many HTTP/1.0 cache implementations will treat an Expires value that is less than or equal to the response Date value as being equivalent to the Cache-Control response directive "no-cache". If an HTTP/1.1 cache receives such a response, and the response does not include a Cache-Control header field, it SHOULD consider the response to be non-cacheable in order to retain compatibility with HTTP/1.0 servers.

Note: An origin server might wish to use a relatively new HTTP cache control feature, such as the "private" directive, on a network including older caches that do not understand that feature. The origin server will need to combine the new feature with an Expires field whose value is less than or equal to the Date value. This will prevent older caches from improperly caching the response.

s-maxage
If a response includes an s-maxage directive, then for a shared cache (but not for a private cache), the maximum age specified by this directive overrides the maximum age specified by either the max-age directive or the Expires header. The s-maxage directive also implies the semantics of the proxy-revalidate directive (see section 14.9.4), i.e., that the shared cache must not use the entry after it becomes stale to respond to a subsequent request without first revalidating it with the origin server. The s- maxage directive is always ignored by a private cache.

Note: that most older caches, not compliant with this specification, do not implement any Cache-Control cache-control directives. An origin server wishing to use a Cache-Control cache-control directive that restricts, but does not prevent, caching by an HTTP/1.1-compliant cache may MAY exploit the requirement that the max-age directive overrides the Expires header, and the fact that pre-HTTP/1.1-compliant caches do not observe the max-age directive.

Other directives allow an user agent to modify the basic expiration mechanism. These directives may MAY be specified on a request:

max-age
Indicates that the client is willing to accept a response whose age is no greater than the specified time in seconds. Unless max-stale directive is also included, the client is not willing to accept a stale response.
min-fresh
Indicates that the client is willing to accept a response whose freshness lifetime is no less than its current age plus the specified time in seconds. That is, the client wants a response that will still be fresh for at least the specified number of seconds.
max-stale
Indicates that the client is willing to accept a response that has exceeded its expiration time. If max-stale is assigned a value, then the client is willing to accept a response that has exceeded its expiration time by no more than the specified number of seconds. If no value is assigned to max-stale, then the client is willing to accept a stale response of any age.

If a cache returns a stale response, either because of a max-stale directive on a request, or because the cache is configured to override the expiration time of a response, the cache MUST attach a Warning header to the stale response, using Warning 110 (Response is stale).

A cache MAY be configured to return stale responses without validation, but only if this does not conflict with any "MUST"-level requirements concerning cache validation (e.g., a "must-revalidate" cache-control directive).

If both the new request and the cached entry include "max-age" directives, then the lesser of the two values is used for determining the freshness of the cached entry for that request.

14.9.4 Cache Revalidation and Reload Controls キャッシュ再検証及び再読み込み制御

Sometimes an user agent may might want or need to insist that a cache revalidate its cache entry with the origin server (and not just with the next cache along the path to the origin server), or to reload its cache entry from the origin server. End-to-end revalidation may might be necessary if either the cache or the origin server has overestimated the expiration time of the cached response. End-to-end reload may be necessary if the cache entry has become corrupted for some reason.

End-to-end revalidation may be requested either when the client does not have its own local cached copy, in which case we call it "unspecified end-to-end revalidation", or when the client does have a local cached copy, in which case we call it "specific end-to-end revalidation."

The client can specify these three kinds of action using Cache-Control request directives:

End-to-end reload
The request includes a "no-cache" Cache-Control cache-control directive or, for compatibility with HTTP/1.0 clients, "Pragma: no-cache". No field Field names may MUST NOT be included with the no-cache directive in a request. The server MUST NOT use a cached copy when responding to such a request.
Specific end-to-end revalidation
The request includes a "max-age=0" Cache-Control cache-control] directive, which forces each cache along the path to the origin server to revalidate its own entry, if any, with the next cache or server. The initial request includes a cache-validating conditional with the client's current validator.
Unspecified end-to-end revalidation
The request includes "max-age=0" Cache-Control cache-control] directive, which forces each cache along the path to the origin server to revalidate its own entry, if any, with the next cache or server. The initial request does not include a cache-validating conditional; the first cache along the path (if any) that holds a cache entry for this resource includes a cache-validating conditional with its current validator.
max-age
When an intermediate cache is forced, by means of a max-age=0 directive, to revalidate its own cache entry, and the client has supplied its own validator in the request, the supplied validator may might differ from the validator currently stored with the cache entry. In this case, the cache may might use either validator in making its own request without affecting semantic transparency.

However, the choice of validator may affect performance. The best approach is for the intermediate cache to use its own validator when making its request. If the server replies with 304 (Not Modified), then the cache should return its now validated copy to the client with a 200 (OK) response. If the server replies with a new entity and cache validator, however, the intermediate cache should can compare the returned validator with the one provided in the client's request, using the strong comparison function. If the client's validator is equal to the origin server's, then the intermediate cache simply returns 304 (Not Modified). Otherwise, it returns the new entity with a 200 (OK) response.

If a request includes the no-cache directive, it should not SHOULD NOT include min-fresh, max-stale, or max-age.

only-if-cached
In some cases, such as times of extremely poor network connectivity, a client may want a cache to return only those responses that it currently has stored, and not to reload or revalidate with the origin server. To do this, the client may include the only-if-cached directive in a request. If it receives this directive, a cache SHOULD either respond using a cached entry that is consistent with the other constraints of the request, or respond with a 504 (Gateway Timeout) status. However, if a group of caches is being operated as a unified system with good internal connectivity, such a request MAY be forwarded within that group of caches.
must-revalidate
Because a cache may MAY be configured to ignore a server's specified expiration time, and because a client request may MAY include a max-stale directive (which has a similar effect), the protocol also includes a mechanism for the origin server to require revalidation of a cache entry on any subsequent use. When the must-revalidate directive is present in a response received by a cache, that cache MUST NOT use the entry after it becomes stale to respond to a subsequent request without first revalidating it with the origin server. (I.e., the cache must MUST do an end-to-end revalidation every time, if, based solely on the origin server's Expires or max-age value, the cached response is stale.)

The must-revalidate directive is necessary to support reliable operation for certain protocol features. In all circumstances an HTTP/1.1 cache MUST obey the must-revalidate directive; in particular, if the cache cannot reach the origin server for any reason, it MUST generate a 504 (Gateway Timeout) response.

Servers should SHOULD send the must-revalidate directive if and only if failure to revalidate a request on the entity could result in incorrect operation, such as a silently unexecuted financial transaction. Recipients MUST NOT take any automated action that violates this directive, and MUST NOT automatically provide an unvalidated copy of the entity if revalidation fails.

Although this is not recommended, user agents operating under severe connectivity constraints may MAY violate this directive but, if so, MUST explicitly warn the user that an unvalidated response has been provided. The warning MUST be provided on each unvalidated access, and SHOULD require explicit user confirmation.

proxy-revalidate
The proxy-revalidate directive has the same meaning as the must-revalidate directive, except that it does not apply to non-shared user agent caches. It can be used on a response to an authenticated request to permit the user's cache to store and later return the response without needing to revalidate it (since it has already been authenticated once by that user), while still requiring proxies that service many users to revalidate each time (in order to make sure that each user has been authenticated). Note that such authenticated responses also need the public cache control directive in order to allow them to be cached at all.

14.9.5 No-Transform Directive 非変換指令

no-transform 参照。

14.9.6 Cache Control Extensions キャッシュ制御拡張

The Cache-Control header field can be extended through the use of one or more cache-extension tokens, each with an optional assigned value. Informational extensions (those which do not require a change in cache behavior) may MAY be added without changing the semantics of other directives. Behavioral extensions are designed to work by acting as modifiers to the existing base of cache directives. Both the new directive and the standard directive are supplied, such that applications which do not understand the new directive will default to the behavior specified by the standard directive, and those that understand the new directive will recognize it as modifying the requirements associated with the standard directive. In this way, extensions to the Cache-Control cache-control directives can be made without requiring changes to the base protocol.

This extension mechanism depends on an HTTP cache obeying all of the cache-control directives defined for its native HTTP-version, obeying certain extensions, and ignoring all directives that it does not understand.

For example, consider a hypothetical new response directive called "community" which acts as a modifier to the "private" directive. We define this new directive to mean that, in addition to any non-shared cache, any cache which is shared only by members of the community named within its value may cache the response. An origin server wishing to allow the "UCI" community to use an otherwise private response in their shared cache(s) may could do so by including

  • Cache-Control: private, community="UCI"

A cache seeing this header field will act correctly even if the cache does not understand the "community" cache-extension, since it will also see and understand the "private" directive and thus default to the safe behavior.

Unrecognized cache-directives MUST be ignored; it is assumed that any cache-directive likely to be unrecognized by an HTTP/1.1 cache will be combined with standard directives (or the response's default cacheability) such that the cache behavior will remain minimally correct even if the cache does not understand the extension(s).

[9] Guidelines for Web Content Transformation Proxies 1.0 ( ( 版)) http://www.w3.org/TR/2010/NOTE-ct-guidelines-20101026/#sec-receipt-of-cache-control-no-transform

[10] #208 (IANA registry for cache-control directives) – httpbis ( ( 版)) http://trac.tools.ietf.org/wg/httpbis/trac/ticket/208

[11] #317 (Cache-Control directive case sensitivity) – httpbis ( ( 版)) http://trac.tools.ietf.org/wg/httpbis/trac/ticket/317

[12] draft-mogul-http-revalidate-01 - Forcing HTTP/1.1 proxies to revalidate responses ( ( 版)) http://tools.ietf.org/html/draft-mogul-http-revalidate-01

[13] RFC 4463 - A Media Resource Control Protocol (MRCP) Developed by Cisco, Nuance, and Speechworks ( ( 版)) http://tools.ietf.org/html/rfc4463#section-5.4.10

[14] RFC 2326 - Real Time Streaming Protocol (RTSP) ( ( 版)) http://tools.ietf.org/html/rfc2326#section-12.8

[15] RFC 6787 - Media Resource Control Protocol Version 2 (MRCPv2) ( ( 版)) http://tools.ietf.org/html/rfc6787#section-6.2.13

[16] RFC 3507 - Internet Content Adaptation Protocol (ICAP) ( ( 版)) http://tools.ietf.org/html/rfc3507#section-4.3.1

RFC 5861

[55] RFC 5861 は追加のキャッシュ指令を2つ規定しています。

実装

[1] Google からの応答に x-gzip-ok="" ってのがついてました。

[7] IE7XHRxhr.setRequestHeader ('Cache-Control', 'no-cache') したら何か変なエラーが出た。。。 IE7 が勝手にキャッシュするから困ってるのにどうすりゃいいのよwwwwww (結局 query にランダム値つけて対処したw)

[305] [HOWTO] Internet Explorer でキャッシュを無効にする ( ( 版)) http://support.microsoft.com/kb/234067

[39] >>38<meta http-equiv=Cache-Control> を実装しているようです。

統計

[5] HTTP/1.1 Cache-Control header ( 版) http://www.http-stats.com/Cache-Control

[3] Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 XOOPS

(名無しさん [sage] 2005-08-18 10:50:21 +00:00)

[6] >>5 より

  • Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: post-check=0, pre-check=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: ,
  • Cache-Control: 7200
  • Cache-Control: "no-cache"
  • Cache-Control: False
  • Cache-Control: no-cache, must-revalidate, no-cache="Set-Cookie", private
  • Cache-Control: post-check=-1, pre-check=-1

関連

[8] 次のヘッダーにはキャッシュ制御に関する規定があります。

[62] EventSource has no need to set Cache-Control · whatwg/html@6f47a53 ( 版) https://github.com/whatwg/html/commit/6f47a53c915ba001cb9e8f7d106a4dcab2a03f98

[63] CDN切り替え作業における、Web版メルカリの個人情報流出の原因につきまして - Mercari Engineering Blog ( ()) http://tech.mercari.com/entry/2017/06/22/204500

切り替え前のCDNプロバイダはCache-Controlヘッダではなく、CDNの設定でキャッシュを制御することで、メルカリWeb版においては全くキャッシュが行われないようにしていました。

切り替え後のCDNプロバイダでは、Cache-Controlヘッダでキャッシュの制御が可能であるため(この制御はnginxの設定により行います)、CDNの設定によるキャッシュ無効化は行わず切り替えを行いました。切替前の検証では手元のマシンのhostsファイルを編集し、数回アクセスを行い問題なく動作していることを確認しました。

問題発覚後に切り替え後CDNのキャッシュの仕様を再度確認したところ、キャッシュをしないのは

Cache-Control: private

が含まれている場合のみとわかりました。Expiresヘッダが過去の日付であっても、Cache-Controlヘッダが存在している場合は利用されないという仕様になっておりました。このためCDNのサーバ上にお客さまの情報が含まれたキャッシュが作成され、別のお客さまへ配信される事態に至りました。

[64] キャッシュの詳細  |  Cloud CDN のドキュメント  |  Google Cloud Platform ( ()) https://cloud.google.com/cdn/docs/caching?hl=ja

次の条件をすべて満たしている場合にのみ、Cloud CDN キャッシュにレスポンスが保存されます。

キャッシュが有効になっているバックエンド サービスから提供されている。

GET リクエストに対するレスポンスである。

ステータス コードが 200、203、300、301、302、307 または 410 である。

Cache-Control: public ディレクティブが設定されている。

Cache-Control: s-maxage、Cache-Control: max-age または Expires ヘッダーがある。

Content-Length ヘッダーまたは Transfer-Encoding ヘッダーがある。

サービス自身が生成した Date ヘッダーがある。HTTP(S) ロードバランサを経由せずに、VM インスタンスに直接リクエストを送信すると、このヘッダーの有無を確認できます。ロードバランサが独自の Date ヘッダーを追加する場合がありますが、このヘッダーだけではキャッシュの条件を満たしません。

レスポンスがキャッシュに保存されるかどうか確認する方法があります。次の条件を満たす場合、レスポンスはキャッシュに保存されません。

Set-Cookie ヘッダーがある。

本体が 4 MB を超えている。

Vary ヘッダーに Accept、Accept-Encoding、Origin 以外の値が設定されている。

Cache-Control: no-store、no-cache または private ディレクティブが設定されている。

対応するリクエストに Cache-Control: no-store ディレクティブが設定されている。

Cloud CDN でキャッシュに保存するレスポンスを増やすため、これらの要件は今後緩和される可能性があります。レスポンスがキャッシュに保存されないようにするには、次の操作を行います。どのキャッシュにもレスポンスを保存しない場合には(ウェブブラウザのキャッシュを含む)、Cache-Control: no-store ヘッダーを追加します。Cloud CDN のキャッシュに保存しない場合には、Cache-Control: private ヘッダーを追加します。

[65] HTTP キャッシュ  |  Web  |  Google Developers () https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching

[66] Cache-Control in the wild () https://www.fastly.com/blog/cache-control-wild

[67] [MS-WMSP]: Cache-Control | Microsoft Docs (openspecs-office著, ) https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wmsp/49b24bb0-6fa5-4bc8-8d60-7c5c554d002c

[68] コンテンツがキャッシュに保持される期間 (有効期限) の管理 - Amazon CloudFront (, ) https://docs.aws.amazon.com/ja_jp/AmazonCloudFront/latest/DeveloperGuide/Expiration.html