Reputation: 4651
I have two files named test.html
and test.php
on my server, having the same content:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>TEMPLATE</title>
</head>
<body>
TEXT
</body>
</html>
Besides that I have a .htaccess
-files with the following content:
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>
Requesting test.html
returns the following headers:
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
After uncommenting the rewrite part (thus using HTML without beeing processed by PHP), the response headers are:
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
It's exactly the same content and exactly the same header, but why is the content not compressed, when it is returned by PHP?
Upvotes: 1
Views: 297
Reputation: 40730
Add the following line in your .htaccess
php_value zlib.output_compression 1
to enable PHP output compression.
More information at http://php.net/manual/en/zlib.configuration.php#ini.zlib.output-compression
Upvotes: 2