Как настроить mod_deflate для обслуживания gzip-архивов, подготовленных с помощью assets: precompile

При запуске задачи Assets: precompile rake создаются сжатые версии ресурсов вашего приложения в сжатом виде. Согласно руководству Rails для конвейера ресурсов, вы можете настроить свой веб-сервер (в моем случае Apache 2.2) для обслуживания этих предварительно сжатых файлов вместо того, чтобы веб-сервер выполнял работу.

Я не могу понять, как настроить mod_deflate так, чтобы эти файлы обслуживаются вместо двойного сжатия, а затем обслуживаются?

У меня включен mod_deflate через httpd.conf:

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, чтобы перейти в .htaccess в public / assets :

# 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>

Есть идеи, как это правильно настроить?

11
задан jrosw 22 September 2011 в 04:16
поделиться