Apache2 mod_deflate static content

apache-2.2mod-deflatestatic-content

I have a server serving up a JS file a few million times a day using apache2. Some of my users would like the JS to be gzipped. Does anyone know how apache2 mod_deflate handles compression of static files? Will it compress the js for each request(in which case I'd be worried about cpu load)? If it does, is there a way to pre-compress the JS files so apache2 wouldn't have to do this for each file?

Best Answer

You can do it with

Options +Multiviews

then precompress the file as whatever.js.gz using

gzip -c -9 whatever.js > whatever.js.gz

However, if there are older browsers that may break with this.

In the apache config

AddEncoding x-gzip .gz

Remove

AddType application/x-gzip .gz
Related Topic