Home  >  Article  >  Backend Development  >  有大神知道SegmentFault的gizp压缩是怎么做到的吗

有大神知道SegmentFault的gizp压缩是怎么做到的吗

WBOY
WBOYOriginal
2016-06-06 20:42:211119browse

有大神知道SegmentFault的gizp压缩是怎么做到的吗

回复内容:

有大神知道SegmentFault的gizp压缩是怎么做到的吗

PHP 可以直接配置成自动 gzip。

  1. 修改 PHP.ini 中 zlib.output_compression 的值为 On
  2. 激活 zlib.output_compression_level,并让其等于 1-5 中的一个,这个值是压缩等级,值越大压缩的越狠,同时消耗 CPU 越多。
  3. 检查 zlib.output_handler 是否已经注释掉,如果没有,注释掉它。

如果是用nginx,可以参考这篇文章。

在Server里添加以下配置:

<code>gzip on;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6].";
gzip_types text/plain application/x-javascript text/css text/javascript;
</code>

服務器端的 handler

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn