我有一个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虚拟主机,并且它可以正常工作。谢谢! –