参考: https://teddysun.com/326.html
添加apache2配置文件 /etc/httpd/conf.modules.d/11.gzip.conf, 内容如下:
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
<IfModule deflate_module>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
然后用命令service httpd restart重启apache2,
先用chrome + F12 测试, 果然启用压缩了,
然后使用wget 继续测试,然而在局域网还是没卵用, 本来0.3秒传完 35M, 压缩后0.7秒传完2.6完
wget http://192.168.1.207:8080/getdata.php
35,127,025 111MB/s in 0.3s
wget http://192.168.1.207:8080/getdata.php --header="Accept-Encoding:gzip, deflate, sdch"
2,611,815 3.47MB/s in 0.7s
网友评论