Forum Topic: Compress CSS and JS if mod_deflate and mod_gzip is deactivated?

Forum: .htaccess Forum : General • Posted by Ralf Koller • Updated:

One provider i have to deal with lately has deactivated mod_deflate and mod_zip categorically cuz of the fear of a too high server load. So no chance to take advantage of the useful little mod_deflate snippet for gzip goodness. The only allowed method is zlib via the php.ini for php files. Well for a WordPress install it is fine cuz most of the files are php. But on the downside the largest, which are the css and the js ones, are out of the compression game. Did a bit of a research and wanted to ask if the methods, Jeff posted over at the perishable press, are still the way to go:

does anybody has experiences which of the two methods, each article describes, is the more solid and reliable one. the php only or better the one with php and htaccess snippets? Best regards Ralf

2 Replies to “Compress CSS and JS if mod_deflate and mod_gzip …”

Posted by Ralf Koller •

and on a side note. If i would go with method 2 for CSS and JS there wouldn’t be any module necessary and i could save one php_flag statement? That the htaccess part would simply look like that?

# css & js compression htaccess ruleset
AddHandler application/x-httpd-php .css
php_value auto_prepend_file gzip-css.php
AddHandler application/x-httpd-php .js
php_value auto_prepend_file gzip-js.php
php_flag zlib.output_compression On
Posted by Jeff Starr

Hi Ralf,

As far as I know, the information in the articles is current, but I would test thoroughly just to make sure (likewise for the code included in your second post). If you encounter any weirdness let me know and I’ll try to help.