问题描述
我没有找到关于标准是否允许重复HTTP响应标头的任何规范,但我需要知道这是否会导致兼容性问题。
I have not found any specification about whether duplicate HTTP response headers are allowed by the standard, but I need to know if this will cause compatibility issues.
说我有这样的响应头:
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)/Tomcat-5.5
Cache-Control: no-cache
Cache-Control: no-store
Location: http://localhost:9876/foo.bar
Content-Language: en-US
Content-Length: 0
Date: Mon, 06 Dec 2010 21:18:26 GMT
请注意,有两个 Cache-Control
标头具有不同的值。浏览器是否总是将它们视为Cache-Control:no-cache,no-store?
Notice that there are two Cache-Control
headers with different values. Do browsers always treat them as if they are written like "Cache-Control: no-cache, no-store"?
谢谢。
Su
推荐答案
HTTP RFC2616可用说:
HTTP RFC2616 available here says:
因此,多个具有相同名称的标题是正确的(www-authenticate就是这种情况)如果整个字段值定义为以逗号分隔的值列表。
So, multiple headers with the same name is ok (www-authenticate is such a case) if the entire field-value is defined as a comma-separated list of values.
此处记录了缓存控制:喜欢这个:
Cache-control is documented here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 like this:
Cache-Control = "Cache-Control" ":" 1#cache-directive
#1cache-directive
语法定义了至少一个缓存的列表 - 指令元素(参见此处#values的正式定义:)
The #1cache-directive
syntax defines a list of at least one cache-directive elements (see here for the formal definition of #values: Notational Conventions and Generic Grammar)
所以,是的,
Cache-Control: no-cache, no-store
相当于(订单很重要)
Cache-Control: no-cache
Cache-Control: no-store
这篇关于是否可以接受重复的HTTP响应标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!