I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod_d
What I do:
js
and stylesheets in a css
dir, respectively.In the Apache configuration, I add directives like so:
AddHandler application/x-httpd-php .js
php_value auto_prepend_file gzip-js.php
php_flag zlib.output_compression On
AddHandler application/x-httpd-php .css
php_value auto_prepend_file gzip-css.php
php_flag zlib.output_compression On
gzip-js.php in the js
directory looks like this:
…and gzip-cs.php in the css
directory looks like this:
This may not be the most elegant solution, but it most certainly is a simple one that requires few changes and works well.