我有一個Rails應用程序,所以當我進行預編譯時,也會爲我編譯gzip資產。我用下面的Apache的配置,以滿足了gzip的資產:使用Apache通過HTTPS/SSL提供gzip資產
<Location /assets/>
RewriteEngine on
# Make sure the browser supports gzip encoding before we send it
# without it, Content-Type will be "application/x-gzip"
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]
</Location>
# Also add a content-encoding header to tell the browser to decompress
<FilesMatch \.css\.gz$>
ForceType text/css
Header set Content-Encoding gzip
</FilesMatch>
<FilesMatch \.js\.gz$>
ForceType text/javascript
Header set Content-Encoding gzip
</FilesMatch>
不過,我注意到這不會對https
SSL站點工作。它在http
網站上工作。我如何讓Apache在https
上提供gzip資源?我不需要使用mod_deflate
,因爲當我編譯我的Rails資產時,我的gzip資源已經編譯完成。
此配置坐在哪裏?我會懷疑你有兩個不同的虛擬主機SSL和非SSL,這隻適用於非SSL虛擬主機。 – Capsule
哦,這可能只適用於非SSL的。該配置位於''中。我是否也應該將它複製到''? –
啊,這是問題所在。我已將配置複製到443虛擬主機,並且它可以正常工作。謝謝! –