애셋 : 사전 컴파일 레이크 작업을 실행할 때 gzipped 버전의 앱 애셋이 생성됩니다. 자산 파이프 라인에 대한 레일스 가이드에 따르면, 웹 서버 (나의 경우 아파치 2.2)가 웹 서버에 작업을시키는 대신 미리 압축 된 파일을 제공하도록 설정할 수있다.애셋으로 준비된 gzip 된 애셋을 처리하기 위해 mod_deflate를 구성하는 방법 : 사전 컴파일
내가 알아낼 수없는 것은 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
내가 레일의 코드를 변환 한 공공/자산 htaccess로 들어가 안내 :
나는 mod_deflate가이 값을 httpd.conf를 통해 활성화
# 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>
하나를 아이디어를 올바르게 설정하는 방법?
작은 주석 -이 htaccess로에없는 경우, 그렇지 않으면 -s가 작동하지 않습니다, 디렉토리 섹션에 있어야합니다. – lzap
또한 'text/javascript'대신'application/javascript'를 사용하는 것이 좋습니다. * 스크립팅 미디어 유형 *에 대한 [RFC4329] (https://tools.ietf.org/html/rfc4329)를 참조하십시오. – tne
해야 할 일 \t AddEncoding gzip .gz 그렇지 않으면 –
Torsten