常见实体首部字段总结

实体首部字段是包含在请求报文和响应报文中的实体部分所使用的首部,用于补充内容的更新时间等与实体相关的信息

一、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-ControlEtag 、Vary  (缓存相关)

详细看https://blog.youkuaiyun.com/jiangshangchunjiezi/article/details/104488266

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值