2016-07-01 139 views
1

我有兩個文件名爲我的服務器上test.htmltest.php,具有相同的內容:爲什麼gzip壓縮不適用於PHP處理的文件?

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"/> 
    <title>TEMPLATE</title> 
</head> 
<body> 

    TEXT 

</body> 
</html> 

另外,我有一個.htaccess -files具有以下內容:

RewriteEngine On 
RewriteBase/
RewriteRule ^(.*)\.(php3|php4|php5|php6|html|htm) $1\.php 

AddType x-mapp-php5.5 .php 
AddHandler x-mapp-php5.5 .php 

<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/html 
</Ifmodule> 

請求test.html回報以下標題:

Connection: Keep-Alive 
Content-Type: text/html 
Date: Fri, 01 Jul 2016 08:32:04 GMT 
Keep-Alive: timeout=2, max=200 
Server: Apache 
Transfer-Encoding: chunked 
x-powered-by: PHP/5.5.36 

取消註釋後克重寫部分(因此使用HTML而不與否有關PHP處理),響應頭有:

Accept-Ranges: bytes 
Connection: Keep-Alive 
Content-Encoding: gzip 
Content-Length: 186 
Content-Type: text/html 
Date: Fri, 01 Jul 2016 08:42:22 GMT 
Etag: "xxxxxxxx-xx-xxxxxxxxxxxxx" 
Keep-Alive: timeout=2, max=200 
Last-Modified: Fri, 01 Jul 2016 08:42:03 GMT 
Server: Apache 
Vary: Accept-Encoding 

它是完全相同的內容和完全相同的頭部,但爲什麼是內容不壓縮,當返回它通過PHP?

+0

Apache將無法處理PHP輸出壓縮,因爲這是在PHP的責任。是否啓用PHP輸出壓縮? (http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression) – apokryfos

回答

相關問題