2012-02-22 69 views

回答

3

對於PHP,他們會做得很好。但是,如果您將頁面壓縮回客戶端,您還需要檢查它是否在apache中啓用(假設您使用apache,則需要mod_gzip.c或mod_deflate.c模塊)。

例如: # httpd -l(阿帕奇2)

伊夫也看到了需要實現在過去的.htaccess覆蓋提及:

#compress all text & html: 
AddOutputFilterByType DEFLATE text/html text/plain text/xml 
# Or, compress certain file types by extension: 
<Files *.html> 
SetOutputFilter DEFLATE 
</Files> 
4

隨着

的一個內壓縮的頁面
<?php 
phpinfo(); 
?> 

如果模塊被加載

你可以找到

本網站http://www.gidnetwork.com/tools/gzip-test.php

你可以檢查某個頁面上的壓縮是否啓用。

有了這些,你會看到,如果壓縮足夠你。

1

你可以從PHP編程方式做到這一點:

if (count(array_intersect(['mod_deflate', 'mod_gzip'], apache_get_modules())) > 0) { 
    echo 'compression enabled'; 
} 

這當然不是超級可靠,因爲可能有其他壓縮模塊...