Finally got GZIP Compression to work on all pages!

I’ve been trying for quite a while off and on to get page compression to work on all Magento pages with no luck. Then I finally stumbled upon something that looking back was so obvious!

First, uncommented out the following in the htaccess file as recommended by all the boards ..


<IfModule mod_deflate.c>

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

# Insert filter on all content
SetOutputFilter DEFLATE
# Insert filter on selected content types only
# AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE text/html text/xml application/xml text/css text/plain text/javascript application/x-javascript application/json

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</IfModule>

That didn’t do the trick though. ¬†Checked it with Page Compression Test ¬†and no luck. Tried all kinds of combinations.

Then I moved onto the php.ini file and added “zlib.output_compression = on”. The server didn’t like that and got a server error. Here’s the ah-ah moment though – I checked the error logs and reports and it appeared the server was looking for an additional extenson.

Added a reference to the missing extension and voila! .. worked like a charm – everything was now compressed and Google Webmaster crawl stats showed a huge drop in bytes downloaded and an increase in page load times.

Here’s a copy of the php.ini file. Your situation may be different depending on your web host but the main thing is – if you get an error – check your error logs and reports – the key may be there!

Good luck! .. Here’s the php.ini that works ..


; enable resulting html compression
zlib.output_compression = on

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

Leave a Reply