assets:precompile rake タスクを実行すると、アプリのアセットの gzip バージョンが作成されます。アセット パイプラインの Rails ガイドによると、Web サーバー (私の場合は Apache 2.2) を構成して、Web サーバーに作業を行わせる代わりに、これらの圧縮済みファイルを提供することができます。
私が理解できないのは、これらのファイルが二重圧縮されてから提供されるのではなく、提供されるように mod_deflate を構成する方法です。
httpd.conf で mod_deflate を有効にしています。
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
そして、Rails ガイドのコードを public/assets の .htaccess に変換しました。
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
Header unset Last-Modified
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
# Serve gzipped versions instead of requiring Apache to do the work
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]
# without it, Content-Type will be "application/x-gzip"
<FilesMatch .*\.css.gz>
ForceType text/css
</FilesMatch>
<FilesMatch .*\.js.gz>
ForceType text/javascript
</FilesMatch>
これを適切に設定する方法はありますか?