aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
阅读:4897回复:24

本坛的 brotli 支持?

楼主#
更多 发布于:2016-03-17 21:52
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
1楼#
发布于:2016-03-17 23:30
fang5566:论坛程序不一样吧,老实说phpwind基本半死,估计是没法支持brotli。@fiag回到原帖
这要看 phpwind 是怎么处理输出编码的了

如果 phpwind 本身未处理
直接交给 web server,本坛是 nginx
那么给 nginx 加上相应模块就可以支持

如果 phpwind 本身直接输出编码后的内容
那就需要找 brotli 的 php 扩展
然后对 phpwind 源码做 hack
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
2楼#
发布于:2016-03-17 23:33
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
3楼#
发布于:2016-03-18 15:55
http://caniuse.com/brotli
目前就 firefox 主动开启
blink 及壳需要手动开启一个 flag 的

google 的模块已经处理了对 Accept-Encoding 头的检测
当且仅当包含 br 时才做压缩

总之
坐等
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
4楼#
发布于:2016-03-27 22:14
> curl https://www.firefox.net.cn/ -H "Accept-Encoding: br" -D - -s -o /dev/null
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 27 Mar 2016 14:11:48 GMT
Content-Type: text/html;charset=utf-8
略
Content-Encoding: br
brotli_types 加个 text/html ?
https://github.com/google/ngx_brotli/
Enables on-the-fly compression of responses for the specified MIME types in addition to text/html. The special value * matches any MIME type. Responses with the text/html MIME type are always compressed.
看来是 phpwind 主动编码的?

服务器上放个静态的 html 页面测试下就知道了……
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
5楼#
发布于:2016-03-27 22:39
> curl https://www.firefox.net.cn/themes/forum/default/template/bbs/thread_run.htm -H "Accept-Encoding: gzip, deflate, br" -D - -s -o /dev/null
HTTP/1.1 200 OK
Server: nginx
Date: Sun, 27 Mar 2016 14:33:55 GMT
Content-Type: text/html
略
Content-Encoding: br
看来还真是 phpwind 主动做了编码
后台有设置可以取消么?

https://www.google.com/search?q=gzip+site%3Aphpwind.net
可以确定是 phpwind 的锅了
aaaa007cn
千年狐狸
千年狐狸
  • UID23968
  • 注册日期2008-05-03
  • 最后登录2022-03-07
  • 发帖数1924
  • 经验1138枚
  • 威望1点
  • 贡献值232点
  • 好评度164点
6楼#
发布于:2016-03-29 23:54
fiag:搞定

管理后台没找到,只有修改代码了。

http://www.phpwind.net/read/2849167

conf/application/default.php

'web-apps' => array(...
回到原帖


以论坛首页为例,包括所有 js 脚本、样式表
gzip 编码后共 79,058 字节
brotli 编码后共 74,141 字节
节省 4.8 KB
其中首页本身为 php 动态生成的
gzip 4,762 字节 vs brotli 4,203 字节

参考 Nick Desaulniers 的数据
或许只对 pre-compressed 的静态内容(不经常改动的 js 脚本、样式表)开启 brotli 比较好?
毕竟 on the fly 编码还是挺吃 cpu 的

不过对于页面比较大的
比如 https://www.firefox.net.cn/read-43130
页面本身 137,619 字节
gzip 30,238 字节
brotili 25,290 字节
效果很明显
游客

返回顶部