OneinStack如何启用 Brotli 压缩
![]() | ![]() | ![]() | ![]() |
| 【性价之王】 | 【线路之王】 | 【价格之王】 | 【配置之王】 |
| 【免费之王】 | 【香港首推】 | 【梯子之王】 | 【独服之王】 |

Brotli是由谷歌开发的压缩算法,与其他压缩算法相比,它有着更高的压缩效率。
一般来说我们的VPS主机已经默认开启了GZIP压缩了,而Brotli与GZIP可以同时共存,当同时开启两种压缩算法时,Brotli 压缩等级优先级高于 Gzip。
OneinStack一键脚本开启方法挺简单的,修改一下 OneinStack 的 nginx 升级脚本,下载 Brotli,然后升级 nginx,修改一下配置,重启 nginx 即可。
下载 Brotli
cd oneinstack/srcgit clone https://github.com/google/ngx_brotli.gitcd ngx_brotligit submodule update --init修改 OneinStack 的 nginx 升级脚本
nginx_modules_options 中新增 --add-module=../ngx_brotli,在 oneinstack/include 目录,找到 upgrade_web.sh,将 ./configure ${nginx_configure_args} 修改为:
执行脚本升级 Nginx
~/oneinstack/upgrade.sh启用 Brotli
修改 /usr/local/nginx/conf/nginx.conf 文件,在 http { } 中找到:
##Brotli Compression#brotli on;#brotli_comp_level 6;#brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;将其改为:
##Brotli Compressionbrotli on;brotli_comp_level 6;brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;如果没有这几行,可在 #Gzip Compression 配置结束后增加进去。
然后重启一下 nginx:service nginx restart
Brotli 兼容性
IE 不支持,Edge 15 开始支持,Chrome、Fiox、Safari 等现代浏览器基本上支持。详见:https://caniuse.com/#feat=brotli
建议 Gzip 和 Brotli 同时开启,这样不支持 Brotli 的浏览器可以用 Gzip。比如这样的配置:
#Gzip Compressiongzip on;gzip_buffers 16 8k;gzip_comp_level 6;gzip_http_version 1.1;gzip_min_length 256;gzip_proxied any;gzip_vary on;gzip_types text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml text/javascript application/javascript application/x-javascript text/x-json application/json application/x-web-app-manifest+json text/css text/plain text/x-component font/opentype application/x-font-ttf application/vnd.ms-fontobject image/x-icon;gzip_disable "MSIE [1-6]\.(?!.*SV1)";##Brotli Compressionbrotli on;brotli_comp_level 6;brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;检查 Brotli 是否成功开启
Chrome 打开网页,F12 或者 Ctrl+Shift+I 打开开发者工具,Network -- 选择页面地址 -- Headers,Response Headers 中有 content-encoding: br 表示开启成功。
[Oneinstack]历史优惠活动内容
猜你可能想看的VPS
- 便宜 bigfootservers→10.75 美元 月 可以购买 15全球[VPS测评]
- ShockHosting→$5 月 KVM-1G 200G 1TB 洛杉全球[VPS测评]
- 微信搜索不到附近的人这么办?全球[VPS测评]
- 疯狂猜成语 图猜成语七个脚印上写着轻舟已过万重山是什么成语?全球[VPS测评]
- 魔方云洛杉矶 CN2 GIA 线路 KVM 虚拟架构 VPS 新上优惠全球[VPS测评]
- 教程 宝塔面板搭建妹子图片站 自带爬虫采集 94imm 程序全球[VPS测评]
- BGP.TO→$185 月-E3 1230v3 16GB 2TB 10M日本VPS[主机]
- 优惠 死海网络元旦促销→VPS 业务 75 折起 洛杉矶双向 CN2 线全球[VPS测评]
- 优惠 Namesilo→CO 域名注册 5 年仅需要 7.7 美元 免费全球[VPS测评]
- [黑五]HostDare 全场 KVM 八折 CN2 GIA 洛杉矶年付全球[VPS测评]
- OLVPS→端口转发 100GB 流量 月付 20 元;枣庄联通独服 3全球[VPS测评]
- 如何选购合适的 VPS ?全球[VPS测评]
- 傲游主机洛杉矶CN2GIA VPS八折优惠 2G内存/强制三网CN2G全球[VPS测评]
- 解决Debian9系统环境中文乱码的问题 检查设置UTF-8编码全球[VPS测评]
- 用Memcached、Batcache加速WordPress实现内存级缓全球[VPS测评]
- Cloudcone 新 SC2 套餐,纯SSD,月付1.65美元起;情人全球[VPS测评]
- RAKsmart 服务器限量秒杀,40G防御仅99刀,洛杉矶新品预售,美全球[VPS测评]
- HostGnome OVH高防VPS,480G DDoS防御,可选卢森堡全球[VPS测评]
- 因搜包耽误员工下班,苹果将支付3050万美元赔款全球[VPS测评]
- 戈登云VPS,6折,充值送50%,香港cn2,美国cn云服务器,2核2G美国VPS[主机]
- 6种样式社交论坛网站HTML5模板 - Social全球[VPS测评]
- 快速云:云服务器和vps区别是什么云服务器和vps哪个比较安全2022-全球[VPS测评]
- HostXen:双十一新用户香港、日本vps,送20元代金券,充值300日本VPS[主机]
- 40火伞高压电爬坡更让企业用电于民全球[VPS测评]
- HTML5绿色有机食品电商网站模板 - Organtio全球[VPS测评]
- 跨境电商拔节生长关键期,宁波政协委员月谈会精准助力!全球[VPS测评]
- 快速云:科普云服务器服务器的概念和作用2022-08-2313:26来源全球[VPS测评]
- 为什么大家都选择香港服务器建站香港VPS[主机]
- 阿里云和腾讯云免备案香港云服务器哪个更优惠?香港VPS[主机]
- 很简单的图片不规则布局样式,纯css样式实现的图片瀑布流布局全球[VPS测评]
转载请注明原文地址:http://140.238.13.167:12355/read-222206.html











