1. cliveportman
  2. /code
  3. /gzip-compression-not-working-in-htaccess-use-deflate-instead

Gzip compression not working in .htaccess - use deflate instead

The following code (from here) should work:

	<ifModule mod_gzip.c>
	mod_gzip_on Yes
	mod_gzip_dechunk Yes
	mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
	mod_gzip_item_include handler ^cgi-script$
	mod_gzip_item_include mime ^text/.*
	mod_gzip_item_include mime ^application/x-javascript.*
	mod_gzip_item_exclude mime ^image/.*
	mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

But on some of our servers it doesn't seem to be. I've checked Gzip is enabled and it is but rather than figure it out, just use this instead:

	<IfModule mod_deflate.c>
	  AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/css text/html text/xml

I can't remember where I got that from, but it works. I think deflate is used by gzip.