What is the best plugin for Rails that gzips my webpage output?
什么是Rails最好的插件,gzips我的网页输出?
Edit: The company I am hosting with has stated they will not install mod_deflate
.
编辑:我托管的公司已经声明他们不会安装mod_deflate。
5 个解决方案
#1
12
Unless you are running your Rails application without another webserver (which usually isn't a great idea), you should probably look at your webserver. All major webservers have options to enable gzip. For example, for Apache, you can use mod_deflate.
除非您正在运行没有其他webserver的Rails应用程序(这通常不是一个好主意),否则您可能应该查看您的webserver。所有主要的web服务器都有启用gzip的选项。例如,对于Apache,可以使用mod_deflate。
#2
13
Have you tested to see if it's already enabled? If your hosting provider uses Apache it very well could be there by default.
您测试过它是否已经启用了吗?如果您的主机提供商使用Apache,那么它在默认情况下是可以存在的。
Run this command against your site and see if you get the Content-Encoding: gzip
header.
在站点上运行此命令,查看是否获得内容编码:gzip头。
$ curl --head -H "Accept-Encoding: gzip" http://example.com
#3
4
Have you tried using the deflate middleware? Add use Rack::Deflater
to your config.ru
.
您尝试过使用紧缩中间件吗?增加使用架::平减器到您的配置。ru。
It's how you'd do it with an app running on Heroku (AFAIK since cedar-stack).
这是你在Heroku上运行的应用程序(从雪松堆开始就有了)。
#4
3
If your hosting company does not support mod_deflate it's time for a new hosting company. I think doing this in Ruby would be pretty slow and a pain in the butt.
如果您的托管公司不支持mod_deflate,是时候建立一个新的托管公司了。我认为在Ruby中这样做是非常缓慢的,而且非常痛苦。
#1
12
Unless you are running your Rails application without another webserver (which usually isn't a great idea), you should probably look at your webserver. All major webservers have options to enable gzip. For example, for Apache, you can use mod_deflate.
除非您正在运行没有其他webserver的Rails应用程序(这通常不是一个好主意),否则您可能应该查看您的webserver。所有主要的web服务器都有启用gzip的选项。例如,对于Apache,可以使用mod_deflate。
#2
13
Have you tested to see if it's already enabled? If your hosting provider uses Apache it very well could be there by default.
您测试过它是否已经启用了吗?如果您的主机提供商使用Apache,那么它在默认情况下是可以存在的。
Run this command against your site and see if you get the Content-Encoding: gzip
header.
在站点上运行此命令,查看是否获得内容编码:gzip头。
$ curl --head -H "Accept-Encoding: gzip" http://example.com
#3
4
Have you tried using the deflate middleware? Add use Rack::Deflater
to your config.ru
.
您尝试过使用紧缩中间件吗?增加使用架::平减器到您的配置。ru。
It's how you'd do it with an app running on Heroku (AFAIK since cedar-stack).
这是你在Heroku上运行的应用程序(从雪松堆开始就有了)。
#4
3
If your hosting company does not support mod_deflate it's time for a new hosting company. I think doing this in Ruby would be pretty slow and a pain in the butt.
如果您的托管公司不支持mod_deflate,是时候建立一个新的托管公司了。我认为在Ruby中这样做是非常缓慢的,而且非常痛苦。