实体首部字段是包含在请求报文和响应报文中的实体部分所使用的首部,用于补充内容的更新时间等与实体相关的信息
一、Allow:资源支持访问的HTTP Method类型
比如Options方法的请求,就会返回Allow字段
Allow: GET, HEAD, PUT
二、Accept-Encoding &
Content-Encoding
The Accept-Encoding
request HTTP header advertises which content encoding, usually a compression algorithm, the client is able to understand. Using content negotiation, the server selects one of the proposals, uses it and informs the client of its choice with the Content-Encoding response header.
Accept-Encoding建议内容编码
,通常是压缩算法。 服务器使用内容协商,选择其中一个提议,使用它并通过Content-Encoding响应标头将其选择通知客户端。
服务器也可能不压缩:
- 已经压缩或者二次压缩不能缩小体积(比如图片)
- 服务器负载80%
详细看:https://blog.youkuaiyun.com/jiangshangchunjiezi/article/details/104433176
三、Content-Length:实体主体部分的大小(单位是字节)
若请求和响应含有body,则必须带上此字段
四、Accept-Language &
Content-Language
The Accept-Language
request HTTP header advertises which languages the client is able to understand, and which locale variant is preferred. (By languages, we mean natural languages, such as English, and not programming languages.) Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice with the Content-Language response header.
language与character encodings区别:比如language是中文zh-CN,character encodings是字符集编码(GBK、GB2312、UTF-8)
五、Accept-Charset &
Content-Type:实体主体的媒体类型和编码方式
The Accept-Charset
request HTTP header advertises which character encodings the client understands. Using content negotiation, the server selects one of the encodings, uses it, and informs the client of its choice within the Content-Type response header, usually in a charset=
parameter.
目前,浏览器一般不发Accept-Charset,用默认值在大多数情况下能得到正确的响应。若不合适,则会返回406 Not Acceptable.
字符编码:
https://blog.youkuaiyun.com/jiangshangchunjiezi/article/details/104433308
六、Range & Content-Range
详细看七中参考
七、Last-Modified
经常和条件请求使用比如If-Modified-Since、If-Unmodified-Since
https://blog.youkuaiyun.com/jiangshangchunjiezi/article/details/88581824
八、Expires、Cache-Control、Etag 、Vary (缓存相关)
详细看https://blog.youkuaiyun.com/jiangshangchunjiezi/article/details/104488266