Passa al contenuto principale

4.3.3. Handling a Validation Response (处理验证响应)

🇬🇧 English

Cache handling of a response to a conditional request is dependent upon its status code:

  • A 304 (Not Modified) response status code indicates that the stored response can be updated and reused; see Section 4.3.4.
  • A full response (i.e., one with a payload body) indicates that none of the stored responses nominated in the conditional request is suitable. Instead, the cache MUST use the full response to satisfy the request. The cache MAY store such a response, subject to its constraints (see Section 3).
  • However, if a cache receives a 5xx (Server Error) response while attempting to validate a response, it can either forward this response to the requesting client, or act as if the server failed to respond. In the latter case, the cache MAY send a previously stored response (see Section 4.2.4).

🇨🇳 中文

缓存对条件请求的响应的处理取决于其状态码:

  • 304(未修改)响应状态码表示可以更新和重用存储的响应; 见第4.3.4节。
  • 完整响应(即,具有有效载荷主体的响应)表示条件请求中指定的所有存储响应均不合适。相反,缓存必须 (MUST) 使用完整响应来满足请求。缓存可以 (MAY) 存储此类响应,但需遵守其约束条件(见第3节)。
  • 但是,如果缓存在尝试验证响应时接收到5xx(服务器错误)响应,它可以将此响应转发给请求客户端,或者表现得好像服务器未能响应。在后一种情况下,缓存可以 (MAY) 发送先前存储的响应(见第4.2.4节)。

🇯🇵 日本語

条件付きリクエストへのレスポンスのキャッシュ処理は、そのステータスコードに依存する:

  • 304(Not Modified)レスポンスステータスコードは、保存されたレスポンスを更新して再利用できることを示す; セクション4.3.4を参照。
  • 完全なレスポンス(つまり、ペイロードボディを持つもの)は、条件付きリクエストで指定された保存されたレスポンスのいずれも適切ではないことを示す。代わりに、キャッシュはリクエストを満たすために完全なレスポンスを使用しなければならない (MUST)。キャッシュは、その制約に従って、そのようなレスポンスを保存してもよい (MAY)(セクション3参照)。
  • ただし、キャッシュがレスポンスを検証しようとして5xx(Server Error)レスポンスを受信した場合、このレスポンスを要求クライアントに転送するか、サーバーが応答に失敗したかのように動作できる。後者の場合、キャッシュは以前に保存されたレスポンスを送信してもよい (MAY)(セクション4.2.4参照)。

🇫🇷 Français

Le traitement par le cache d'une réponse à une requête conditionnelle dépend de son code d'état :

  • Un code d'état de réponse 304 (Not Modified) indique que la réponse stockée peut être mise à jour et réutilisée ; voir Section 4.3.4.
  • Une réponse complète (c'est-à-dire une avec un corps de charge utile) indique qu'aucune des réponses stockées désignées dans la requête conditionnelle n'est appropriée. Au lieu de cela, le cache DOIT (MUST) utiliser la réponse complète pour satisfaire la requête. Le cache PEUT (MAY) stocker une telle réponse, sous réserve de ses contraintes (voir Section 3).
  • Cependant, si un cache reçoit une réponse 5xx (Server Error) en tentant de valider une réponse, il peut soit transmettre cette réponse au client demandeur, soit agir comme si le serveur n'avait pas réussi à répondre. Dans ce dernier cas, le cache PEUT (MAY) envoyer une réponse précédemment stockée (voir Section 4.2.4).

🇩🇪 Deutsch

Die Cache-Behandlung einer Antwort auf eine bedingte Anfrage hängt von ihrem Statuscode ab:

  • Ein 304 (Not Modified)-Antwortstatuscode zeigt an, dass die gespeicherte Antwort aktualisiert und wiederverwendet werden kann; siehe Abschnitt 4.3.4.
  • Eine vollständige Antwort (d. h. eine mit einem Payload-Body) zeigt an, dass keine der in der bedingten Anfrage nominierten gespeicherten Antworten geeignet ist. Stattdessen MUSS (MUST) der Cache die vollständige Antwort verwenden, um die Anfrage zu erfüllen. Der Cache DARF (MAY) eine solche Antwort speichern, vorbehaltlich seiner Einschränkungen (siehe Abschnitt 3).
  • Wenn ein Cache jedoch eine 5xx (Server Error)-Antwort erhält, während er versucht, eine Antwort zu validieren, kann er diese Antwort entweder an den anfragenden Client weiterleiten oder so tun, als ob der Server nicht reagiert hätte. Im letzteren Fall DARF (MAY) der Cache eine zuvor gespeicherte Antwort senden (siehe Abschnitt 4.2.4).

🇮🇹 Italiano

La gestione della cache di una risposta a una richiesta condizionale dipende dal suo codice di stato:

  • Un codice di stato di risposta 304 (Not Modified) indica che la risposta memorizzata può essere aggiornata e riutilizzata; vedere Sezione 4.3.4.
  • Una risposta completa (cioè una con un corpo di payload) indica che nessuna delle risposte memorizzate nominate nella richiesta condizionale è adatta. Invece, la cache DEVE (MUST) utilizzare la risposta completa per soddisfare la richiesta. La cache PUÒ (MAY) memorizzare tale risposta, soggetta ai suoi vincoli (vedere Sezione 3).
  • Tuttavia, se una cache riceve una risposta 5xx (Server Error) mentre tenta di validare una risposta, può inoltrare questa risposta al client richiedente, o agire come se il server non fosse riuscito a rispondere. In quest'ultimo caso, la cache PUÒ (MAY) inviare una risposta precedentemente memorizzata (vedere Sezione 4.2.4).

4.3.4. Freshening Stored Responses upon Validation (验证时更新存储的响应)

🇬🇧 English

When a cache receives a 304 (Not Modified) response, it MUST update the header fields of the stored response with the header fields provided in the 304 response, as per RFC 7232, Section 4.1.

The cache MUST also use the updated stored response to satisfy the request that caused the validation and MAY use it to satisfy other requests.

When updating a header field value, the cache MUST delete any Warning header field in the stored response with warn-code 1xx (see Section 5.5) and MUST add to the updated stored response any Warning header fields in the 304 response.

🇨🇳 中文

当缓存接收到304(未修改)响应时,它必须 (MUST) 根据RFC 7232第4.1节,使用304响应中提供的头字段更新存储响应的头字段。

缓存还必须 (MUST) 使用更新后的存储响应来满足引起验证的请求,并且可以 (MAY) 使用它来满足其他请求。

更新头字段值时,缓存必须 (MUST) 删除存储响应中带有warn-code 1xx的任何Warning头字段(见第5.5节),并且必须 (MUST) 将304响应中的任何Warning头字段添加到更新后的存储响应中。

🇯🇵 日本語

キャッシュが304(Not Modified)レスポンスを受信すると、RFC 7232のセクション4.1に従い、304レスポンスで提供されたヘッダーフィールドで保存されたレスポンスのヘッダーフィールドを更新しなければならない (MUST)。

キャッシュはまた、検証を引き起こしたリクエストを満たすために更新された保存されたレスポンスを使用しなければならず (MUST)、他のリクエストを満たすためにそれを使用してもよい (MAY)。

ヘッダーフィールド値を更新する場合、キャッシュは保存されたレスポンス内のwarn-code 1xxを持つすべてのWarningヘッダーフィールドを削除しなければならず (MUST)、304レスポンス内のすべてのWarningヘッダーフィールドを更新された保存されたレスポンスに追加しなければならない (MUST)(セクション5.5参照)。

🇫🇷 Français

Lorsqu'un cache reçoit une réponse 304 (Not Modified), il DOIT (MUST) mettre à jour les champs d'en-tête de la réponse stockée avec les champs d'en-tête fournis dans la réponse 304, conformément à RFC 7232, Section 4.1.

Le cache DOIT (MUST) également utiliser la réponse stockée mise à jour pour satisfaire la requête qui a causé la validation et PEUT (MAY) l'utiliser pour satisfaire d'autres requêtes.

Lors de la mise à jour d'une valeur de champ d'en-tête, le cache DOIT (MUST) supprimer tout champ d'en-tête Warning dans la réponse stockée avec warn-code 1xx (voir Section 5.5) et DOIT (MUST) ajouter à la réponse stockée mise à jour tous les champs d'en-tête Warning dans la réponse 304.

🇩🇪 Deutsch

Wenn ein Cache eine 304 (Not Modified)-Antwort erhält, MUSS (MUST) er die Header-Felder der gespeicherten Antwort mit den in der 304-Antwort bereitgestellten Header-Feldern gemäß RFC 7232, Abschnitt 4.1, aktualisieren.

Der Cache MUSS (MUST) auch die aktualisierte gespeicherte Antwort verwenden, um die Anfrage zu erfüllen, die die Validierung verursacht hat, und DARF (MAY) sie verwenden, um andere Anfragen zu erfüllen.

Beim Aktualisieren eines Header-Feldwerts MUSS (MUST) der Cache jedes Warning-Header-Feld in der gespeicherten Antwort mit warn-code 1xx löschen (siehe Abschnitt 5.5) und MUSS (MUST) alle Warning-Header-Felder in der 304-Antwort zur aktualisierten gespeicherten Antwort hinzufügen.

🇮🇹 Italiano

Quando una cache riceve una risposta 304 (Not Modified), DEVE (MUST) aggiornare i campi di intestazione della risposta memorizzata con i campi di intestazione forniti nella risposta 304, secondo RFC 7232, Sezione 4.1.

La cache DEVE (MUST) anche utilizzare la risposta memorizzata aggiornata per soddisfare la richiesta che ha causato la validazione e PUÒ (MAY) utilizzarla per soddisfare altre richieste.

Quando aggiorna un valore di campo di intestazione, la cache DEVE (MUST) eliminare qualsiasi campo di intestazione Warning nella risposta memorizzata con warn-code 1xx (vedere Sezione 5.5) e DEVE (MUST) aggiungere alla risposta memorizzata aggiornata qualsiasi campo di intestazione Warning nella risposta 304.


4.3.5. Freshening Responses via HEAD (通过HEAD更新响应)

🇬🇧 English

A response to the HEAD method is identical to what an equivalent request made with a GET would have been, except that it lacks a body. This property of HEAD responses allows a cache to update a stored response without transferring the entire response content. Therefore, a cache MAY use a HEAD response to update a cached GET response if the HEAD response has a Last-Modified and/or ETag field value(s) that matches those of the stored GET response.

When updating a stored response using a HEAD response, the cache MUST update the stored response's header fields with the header field values provided in the HEAD response.

🇨🇳 中文

HEAD方法的响应与使用GET进行的等效请求的响应相同,只是它缺少主体。HEAD响应的此属性允许缓存在不传输整个响应内容的情况下更新存储的响应。因此,如果HEAD响应具有与存储的GET响应匹配的Last-Modified和/或ETag字段值,则缓存可以 (MAY) 使用HEAD响应来更新缓存的GET响应。

当使用HEAD响应更新存储的响应时,缓存必须 (MUST) 使用HEAD响应中提供的头字段值更新存储响应的头字段。

🇯🇵 日本語

HEADメソッドへのレスポンスは、GETで行った同等のリクエストと同一であるが、ボディが欠けている点が異なる。HEADレスポンスのこの特性により、キャッシュはレスポンスコンテンツ全体を転送せずに保存されたレスポンスを更新できる。したがって、HEADレスポンスに保存されたGETレスポンスと一致するLast-ModifiedおよびETagフィールド値がある場合、キャッシュはHEADレスポンスを使用してキャッシュされたGETレスポンスを更新してもよい (MAY)。

HEADレスポンスを使用して保存されたレスポンスを更新する場合、キャッシュはHEADレスポンスで提供されたヘッダーフィールド値で保存されたレスポンスのヘッダーフィールドを更新しなければならない (MUST)。

🇫🇷 Français

Une réponse à la méthode HEAD est identique à ce qu'aurait été une requête équivalente faite avec GET, sauf qu'elle manque un corps. Cette propriété des réponses HEAD permet à un cache de mettre à jour une réponse stockée sans transférer l'intégralité du contenu de la réponse. Par conséquent, un cache PEUT (MAY) utiliser une réponse HEAD pour mettre à jour une réponse GET en cache si la réponse HEAD a une ou des valeurs de champ Last-Modified et/ou ETag qui correspondent à celles de la réponse GET stockée.

Lors de la mise à jour d'une réponse stockée à l'aide d'une réponse HEAD, le cache DOIT (MUST) mettre à jour les champs d'en-tête de la réponse stockée avec les valeurs de champ d'en-tête fournies dans la réponse HEAD.

🇩🇪 Deutsch

Eine Antwort auf die HEAD-Methode ist identisch mit dem, was eine gleichwertige Anfrage mit GET gewesen wäre, außer dass ihr ein Body fehlt. Diese Eigenschaft von HEAD-Antworten ermöglicht es einem Cache, eine gespeicherte Antwort zu aktualisieren, ohne den gesamten Antwortinhalt zu übertragen. Daher DARF (MAY) ein Cache eine HEAD-Antwort verwenden, um eine zwischengespeicherte GET-Antwort zu aktualisieren, wenn die HEAD-Antwort Last-Modified- und/oder ETag-Feldwert(e) hat, die mit denen der gespeicherten GET-Antwort übereinstimmen.

Beim Aktualisieren einer gespeicherten Antwort mit einer HEAD-Antwort MUSS (MUST) der Cache die Header-Felder der gespeicherten Antwort mit den in der HEAD-Antwort bereitgestellten Header-Feldwerten aktualisieren.

🇮🇹 Italiano

Una risposta al metodo HEAD è identica a ciò che sarebbe stata una richiesta equivalente fatta con GET, tranne per il fatto che manca un corpo. Questa proprietà delle risposte HEAD consente a una cache di aggiornare una risposta memorizzata senza trasferire l'intero contenuto della risposta. Pertanto, una cache PUÒ (MAY) utilizzare una risposta HEAD per aggiornare una risposta GET memorizzata nella cache se la risposta HEAD ha valori di campo Last-Modified e/o ETag che corrispondono a quelli della risposta GET memorizzata.

Quando aggiorna una risposta memorizzata utilizzando una risposta HEAD, la cache DEVE (MUST) aggiornare i campi di intestazione della risposta memorizzata con i valori dei campi di intestazione forniti nella risposta HEAD.


4.4. Invalidation (失效)

🇬🇧 English

The purpose of cache invalidation is to eliminate responses whose actual response value (not header fields) is likely to be significantly different from the invalidated response, thereby avoiding confusion if the two are presented as alternatives.

When a cache receives a request with a method that may result in an update to stored responses (e.g., PUT, POST, or DELETE; see Section 4.2.1 of [RFC7231]), it MUST consider all stored responses for the effective request URI (Section 5.5 of [RFC7230]) to be invalidated, along with those for the URI(s) in the Location and Content-Location response header fields (if present).

However, a cache MUST NOT invalidate a URI that appears in the Location or Content-Location response header fields if the response status code is a redirect and the host component in that URI differs from the effective request URI's host.

A cache MUST invalidate the effective request URI (Section 5.5 of [RFC7230]) when it receives a non-error response to a request with a method whose semantics imply that the state of the target resource might have been changed (e.g., PUT, POST, DELETE, and PATCH).

🇨🇳 中文

缓存失效的目的是消除其实际响应值(而非头字段)可能与失效响应显著不同的响应,从而避免在将两者作为替代方案呈现时产生混淆。

当缓存接收到可能导致存储响应更新的方法的请求时(例如,PUT、POST或DELETE; 见 [RFC7231] 的第4.2.1节),它必须 (MUST) 将有效请求URI([RFC7230] 的第5.5节)的所有存储响应以及Location和Content-Location响应头字段(如果存在)中的URI的所有存储响应视为失效。

但是,如果响应状态码是重定向,并且该URI中的主机组件与有效请求URI的主机不同,则缓存不得 (MUST NOT) 使出现在Location或Content-Location响应头字段中的URI失效。

当缓存接收到对语义暗示目标资源状态可能已更改的方法的请求的非错误响应时(例如,PUT、POST、DELETE和PATCH),它必须 (MUST) 使有效请求URI([RFC7230] 的第5.5节)失效。

🇯🇵 日本語

キャッシュ無効化の目的は、実際のレスポンス値(ヘッダーフィールドではない)が無効化されたレスポンスと大きく異なる可能性が高いレスポンスを排除し、2つが代替として提示される場合の混乱を回避することである。

キャッシュが、保存されたレスポンスの更新につながる可能性のあるメソッドを含むリクエストを受信した場合(例えば、PUT、POST、またはDELETE; [RFC7231] のセクション4.2.1を参照)、有効なリクエストURI([RFC7230] のセクション5.5)のすべての保存されたレスポンス、およびLocationおよびContent-Locationレスポンスヘッダーフィールド(存在する場合)内のURIのすべての保存されたレスポンスを無効と見なさなければならない (MUST)。

ただし、レスポンスステータスコードがリダイレクトであり、そのURI内のホストコンポーネントが有効なリクエストURIのホストと異なる場合、キャッシュはLocationまたはContent-Locationレスポンスヘッダーフィールドに表示されるURIを無効化してはならない (MUST NOT)。

キャッシュは、ターゲットリソースの状態が変更された可能性があることを意味するセマンティクスを持つメソッドへのリクエストに対する非エラーレスポンスを受信した場合(例えば、PUT、POST、DELETE、およびPATCH)、有効なリクエストURI([RFC7230] のセクション5.5)を無効化しなければならない (MUST)。

🇫🇷 Français

Le but de l'invalidation de cache est d'éliminer les réponses dont la valeur de réponse réelle (et non les champs d'en-tête) est susceptible d'être significativement différente de la réponse invalidée, évitant ainsi toute confusion si les deux sont présentées comme alternatives.

Lorsqu'un cache reçoit une requête avec une méthode qui peut entraîner une mise à jour des réponses stockées (par exemple, PUT, POST ou DELETE ; voir Section 4.2.1 de [RFC7231]), il DOIT (MUST) considérer toutes les réponses stockées pour l'URI de requête effective (Section 5.5 de [RFC7230]) comme invalidées, ainsi que celles pour les URI dans les champs d'en-tête de réponse Location et Content-Location (s'ils sont présents).

Cependant, un cache NE DOIT PAS (MUST NOT) invalider un URI qui apparaît dans les champs d'en-tête de réponse Location ou Content-Location si le code d'état de réponse est une redirection et que le composant hôte dans cet URI diffère de l'hôte de l'URI de requête effective.

Un cache DOIT (MUST) invalider l'URI de requête effective (Section 5.5 de [RFC7230]) lorsqu'il reçoit une réponse non-erreur à une requête avec une méthode dont la sémantique implique que l'état de la ressource cible pourrait avoir été modifié (par exemple, PUT, POST, DELETE et PATCH).

🇩🇪 Deutsch

Der Zweck der Cache-Invalidierung besteht darin, Antworten zu eliminieren, deren tatsächlicher Antwortwert (nicht Header-Felder) wahrscheinlich erheblich von der invalidierten Antwort abweicht, wodurch Verwirrung vermieden wird, wenn die beiden als Alternativen präsentiert werden.

Wenn ein Cache eine Anfrage mit einer Methode erhält, die zu einer Aktualisierung gespeicherter Antworten führen kann (z. B. PUT, POST oder DELETE; siehe Abschnitt 4.2.1 von [RFC7231]), MUSS (MUST) er alle gespeicherten Antworten für den effektiven Anfrage-URI (Abschnitt 5.5 von [RFC7230]) sowie diejenigen für die URIs in den Location- und Content-Location-Antwort-Header-Feldern (falls vorhanden) als invalidiert betrachten.

Ein Cache DARF jedoch NICHT (MUST NOT) einen URI invalidieren, der in den Location- oder Content-Location-Antwort-Header-Feldern erscheint, wenn der Antwortstatuscode eine Weiterleitung ist und die Hostkomponente in diesem URI vom Host des effektiven Anfrage-URI abweicht.

Ein Cache MUSS (MUST) den effektiven Anfrage-URI (Abschnitt 5.5 von [RFC7230]) invalidieren, wenn er eine Nicht-Fehler-Antwort auf eine Anfrage mit einer Methode erhält, deren Semantik impliziert, dass der Zustand der Zielressource möglicherweise geändert wurde (z. B. PUT, POST, DELETE und PATCH).

🇮🇹 Italiano

Lo scopo dell'invalidazione della cache è eliminare le risposte il cui valore di risposta effettivo (non i campi di intestazione) è probabilmente significativamente diverso dalla risposta invalidata, evitando così confusione se le due vengono presentate come alternative.

Quando una cache riceve una richiesta con un metodo che può comportare un aggiornamento delle risposte memorizzate (ad esempio, PUT, POST o DELETE; vedere Sezione 4.2.1 di [RFC7231]), DEVE (MUST) considerare tutte le risposte memorizzate per l'URI di richiesta effettivo (Sezione 5.5 di [RFC7230]) come invalidate, insieme a quelle per gli URI nei campi di intestazione di risposta Location e Content-Location (se presenti).

Tuttavia, una cache NON DEVE (MUST NOT) invalidare un URI che appare nei campi di intestazione di risposta Location o Content-Location se il codice di stato della risposta è un reindirizzamento e il componente host in quell'URI differisce dall'host dell'URI di richiesta effettivo.

Una cache DEVE (MUST) invalidare l'URI di richiesta effettivo (Sezione 5.5 di [RFC7230]) quando riceve una risposta non di errore a una richiesta con un metodo la cui semantica implica che lo stato della risorsa di destinazione potrebbe essere stato modificato (ad esempio, PUT, POST, DELETE e PATCH).


📝 翻译说明 (Translation Notes)

  • 4.3.3 状态码处理: 304、5xx响应的处理逻辑在所有语言版本中保持了严格的RFC 2119关键词使用
  • 4.3.4 响应更新: Warning头字段的1xx warn-code删除规则在所有语言中得到了精确传达
  • 4.3.5 HEAD优化: HEAD方法作为验证优化手段的机制在所有语言版本中都得到了准确描述
  • 4.4 失效机制: PUT、POST、DELETE等unsafe方法触发的缓存失效规则在所有语言中保持了法律级严谨性
  • Location/Content-Location: 重定向场景下的主机组件检查是关键安全机制,所有语言版本都准确传达了这一要求