WordPress / Apache 2 mod_deflate not compressing all javascript files.

Categories: Tech
Written By: Scott

I don’t think this is wordpress specific, but this where I wanted to categorize this one.

I knew enough to enable mod_deflate on apache right from the go, but the other day I was dinking with firebug/yslow ( excellent article on putting yslow results in perspective ) and noticed that most of my js files weren’t being compressed. I’ve got access to the server, and I can’t see any reason not to enable gzip across the board, so all my deflate stuff was in httpd.conf. Why were some js being compressed but not all?

And then I finally googled upon somebody else having the same issue who had found a solution. Insert the following in the .htaccess file for the site:


<IfModule deflate_module> (or mod_deflate.c for non-win32 apache installs)
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

I’m not happy about having to put this in each site’s htaccess, and I know if I don’t record this it’s going to bite me in the ass later when I need to do this again, so that’s why this post is here.

Reply to “WordPress / Apache 2 mod_deflate not compressing all javascript files.”

Featured & Popular Articles