- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如果您对资源执行 GET
请求,那么您可以获得 Not Modified 响应以避免不必要的流量是非常有意义的。
问题是为什么返回码是304
?这意味着它是一个重定向 响应。在这种情况下,预期的重定向位置是什么?
我原以为它是 2xx
范围内的东西,因为它是一个成功请求和一个有效的答案。
参见 RFC .
最佳答案
请不要再使用过时的旧 RFC 2616 作为引用。它已被 RFC 7230-35 完全废弃,它们一起定义了 HTTP 协议(protocol)。
如 RFC 7231 中所述,有几种类型的重定向,其中一种是到缓存资源的隐式重定向,如 304
所示状态代码(突出显示是我的):
The
3xx
(Redirection) class of status code indicates that furtheraction needs to be taken by the user agent in order to fulfill therequest. [...]There are several types of redirects:
Redirects that indicate the resource might be available at adifferent URI, as provided by the
Location
field, as in thestatus codes301
(Moved Permanently),302
(Found), and307
(Temporary Redirect).Redirection that offers a choice of matching resources, eachcapable of representing the original request target, as in the
300
(Multiple Choices) status code.Redirection to a different resource, identified by the
Location
field, that can represent an indirect response to the request, asin the303
(See Other) status code.Redirection to a previously cached result, as in the
304
(NotModified) status code.
The
304
(Not Modified) status code indicates that a conditionalGET
orHEAD
request has been received and would have resulted in a200
(OK) response if it were not for the fact that the conditionevaluated to false. In other words, there is no need for the serverto transfer a representation of the target resource because therequest indicates that the client, which made the requestconditional, already has a valid representation; the server istherefore redirecting the client to make use of that storedrepresentation as if it were the payload of a200
(OK) response.
关于http - 为什么 "Not Modified"是重定向 ("3xx") 状态码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51763977/
我是一名优秀的程序员,十分优秀!