Mickey,
Its more or less what I use:
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType "text/javascript" .js.jgz
AddEncoding gzip .jgz
Dont know which is best, but as I understood now its the broswer that unzip the pre-gzipped file, so there is no cpu usage, so its safe to use.
I read that its better to change the filename to .jgz because safari has a bug and dont get .gz
[
tutorialajax.com...]
however this is from 2008 and dont know if still the same, also I read that chrome has the same bug.
And to check I did check with chrome and chrome does not serve the gzipped file.....in safari I dont know how to see if it does, however firefox does serve it.
Now the strange thing, as it did not work in chrome I changed the extension .jgz to .gz and uploaded the .gz file, also I changed the extension in .htaccess, and firefox and chrome did not serve the .gz file and the .js file either. And then I tried with your code and the same. Dont know if server blocked .gz files or I should write something else in the .htaccess file to use .gz instead of .jgz.
Edited, just tested jdMorgand code and did not work either..
# If client accepts compressed files
RewriteCond %{HTTP:Accept-Encoding} gzip
# and if compressed file exists
RewriteCond %{REQUEST_FILENAME}.gz -f
# send .html.gz instead of .html
RewriteRule ^(.+\.js)$ /$1.gz [L]