0

I've edited my php.ini file so that it has these two entries:

zlib.output_compression = On
zlib.output_compression_level = 4

However, after restarting apache, when I request php pages, the headers returned in the response indicate that my server is still NOT serving compressed pages (here are selected headers as viewed using Chrome's Network feature):

Cache-Control:no-cache, must-revalidate, max-age=0
Connection:Keep-Alive
Content-Type:text/html; charset=UTF-8
Date:Mon, 17 Sep 2012 23:46:13 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Mon, 17 Sep 2012 23:46:13 GMT
Pragma:no-cache
Proxy-Connection:Keep-Alive
Server:Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.17
Transfer-Encoding:chunked
Via:1.1 XXX-PRXY-07
X-Powered-By:PHP/5.2.17

What might I be doing wrong? Is there any other setting that I need to change?

EDIT

Here is another set of headers returned to another computer:

Cache-Control:no-cache, must-revalidate, max-age=0
Connection:close
Content-Type:text/html; charset=UTF-8
Date:Thu, 20 Sep 2012 09:45:26 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Thu, 20 Sep 2012 09:45:26 GMT
Pragma:no-cache
Server:Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.17
Transfer-Encoding:chunked
Vary:Cookie
X-Powered-By:PHP/5.2.17
Tola Odejayi
  • 334
  • 1
  • 4
  • 19
  • What is your goal exactly? Typically, you would disable zlib in PHP and have Apache use mod_deflate to return the resultant HTML in a gzipped format. – Ben Lessani Sep 21 '12 at 08:52

2 Answers2

2

It looks like the traffic is being proxied. Verify the proxy can handle compressed traffic and isn't decompressing it for some reason.

If the client (the proxy in this case, but in many cases the end user's browser) doesn't support the compression in use, traffic will not be compressed.

I also notice that neither mod_zlib or mod_deflate seem to be loaded. You may need to check that the module is working and configured (you might have to add a define option to apache startup, or enable a config file).

Falcon Momot
  • 25,244
  • 15
  • 63
  • 92
  • Hi, thanks for answering. I don't think that the proxy is the issue here: I tried accessing the site from another computer that wasn't sitting behind a proxy, and I'm still getting uncompressed data in response. I've edited my original response to show the headers returned to this second computer. – Tola Odejayi Sep 20 '12 at 09:47
  • 1
    Hi Falcon Momot. Your edit put me on the right track; I did have mod_deflate installed, but it wasn't configured to be used in apache. Thanks - you deserve your 50 points! – Tola Odejayi Sep 24 '12 at 17:44
1

Either your php.ini file is not being read or your zlib module isn't loaded. Also make sure that output_handler is not set. If you need to use an output handler with gzipped output, use zlib.output_handler instead.

The first thing to do is ensure that PHP knows about zlib and your configuration changes. Create a file called test.php and put the following in it.

<?php phpinfo(); ?>

Now access that page with your browser. What does the table for the zlib section say? It should look like this and, if it does, your page should be served with gzip content-encoding. If you don't see a zlib section then you may need to add a directive in php.ini to load the module.

Screen capture of phpinfo() zlib details

Also check the Core section of the page to make sure that output_handler is set to no value.

Screen capture of phpinfo() output_handler details

Starfish
  • 2,735
  • 25
  • 28