我有apap版本2.4.25和PHP 5.6的XAMPP,然后我在apache文件夹中的httpd.conf上启用了mod_deflate和mod_filter:
LoadModule deflate_module modules/mod_deflate.so
LoadModule deflate_module modules/mod_filter.so
我安装了一个新的codeignter框架,然后在根文件夹中写一个.httaccess文件,如下所示:
RewriteEngine on
#RewriteBase /suli5
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
# compress text, html, javascript, css, xml:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/jpg
AddOutputFilterByType DEFLATE text/html
# DEFLATE NOT COMPATIBLE BROWERS
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
重启apache然后我想验证压缩gzip是否运行,所以我检查
curl -I -H"Accept-Encoding: gzip" http://localhost/nees/
,但仍然没有
Content-Encoding: gzip
只给我这样:
TP/1.1 200 OK
Date: Thu, 27 Jul 2017 03:26:00 GMT
Server: Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30
X-Powered-By: PHP/5.6.30
Set-Cookie: ci_session=vmbl2tgvt838hb9mlbrg226f4hu7j43u; expires=Thu, 27-Jul-2017 05:26:00 GMT; Max-Age=7200; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Type: text/html; charset=UTF-8
如何检查我的mod_deflate是否运行良好?
答案 0 :(得分:0)
就我而言,我将其设置为httpd.conf:
<IfModule deflate_module>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog "logs/deflate_log" deflate
</IfModule>
请注意, - deflate_module它是我的mod_deflate的别名。