个人博客 个人博客
首页
  • 前端
  • 后端
  • Git
  • Docker
  • 网络
  • 操作系统
工具
阅读
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

董先亮

前端react开发
首页
  • 前端
  • 后端
  • Git
  • Docker
  • 网络
  • 操作系统
工具
阅读
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • http压缩
    • 介绍
    • Content-Encoding与Accept-Encoding
      • 作用
      • 压缩方式
      • 使用
  • 状态码
  • 网络
NeverStop1024
2022-06-13
目录

http压缩

# 介绍

当服务器收到请求时,会从请求头Accept-Encoding中,选择一种服务器可以压缩的方式,进行压缩返回。
如果请求头不存在Accept-Encoding,服务器会假设接受所有压缩方式。

# Content-Encoding与Accept-Encoding

设置压缩格式后,服务器会根据设置的规则对资源进行压缩,节省http请求流量

# 作用

  • Accept-Encoding客户端能识别的压缩方式
  • Content-Encoding服务器对资源进行了何种压缩方式

# 压缩方式

  • gzip  表明实体采用GNU zip编码(使用最多)
  • compress 表明实体采用Unix的文件压缩程序
  • deflate 表明实体是用zlib的格式压缩的
  • identity 表明没有对实体进行编码。当没有Content-Encoding header时, 就默认为这种情况
  • br 新的压缩算法brotli,(百度、掘金等网站也都在使用)

# 使用

可以是一个或多个,用逗号隔开

Accept-Encoding: gzip, deflate, br

编辑 (opens new window)
上次更新: 2022/08/25
状态码

状态码→

最近更新
01
mock使用
07-12
02
websocket即时通讯
07-12
03
前端面试题
07-09
更多文章>
Theme by Vdoing | Copyright © 2022-2023 NeverStop1024 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式