浏览器缓存如何确定请求是否相同?

How browser cache determine that request is same or not?

我了解到浏览器会保存响应,以便在下一个 same request 快速 return。
但这里的问题是,什么是same request?在Get请求的情况下是否意味着same resource uri

请求中包含的header的值或者body的内容呢?

我看到 Cache-Control header 也用于 Post 请求。

如果是,同一个Post请求的标准是通过比较body的内容来确定的吗?

RFC 7234 defines 缓存键:

The primary cache key consists of the request method and target URI.... If a request target is subject to content negotiation, its cache entry might consist of multiple stored responses, each differentiated by a secondary key for the values of the original request's selecting header fields.

辅助密钥使用 Vary 响应 header 中列出的 header。有关详细信息,请参阅 section 4.1

When a cache receives a request that can be satisfied by a stored response that has a Vary header field, it MUST NOT use that response unless all of the selecting header fields nominated by the Vary header field match in both the original request (i.e., that associated with the stored response), and the presented request.

回答您的具体问题:

But the question here is, what is the same request? Does it mean the same resource URI in the case of a GET request?

是的。

What about the values ​​of headers included in the request or the content of the body?

body 的内容无关紧要,header 仅在 Vary header.[=26 中列出时才重要=]

I've seen that the Cache-Control header is also used for POST requests. If so, is the standard for the same Post request determined by comparing the contents of the body?

由于主缓存键由 URI 和方法组成,如果两个 POST 请求具有相同的 URI,它们将具有相同的键。然而,作为标准 notes,“由于当今常用的 HTTP 缓存通常是有限的 缓存对 GET 的响应,许多缓存只是简单地拒绝其他方法 并仅使用 URI 作为主缓存键。"