作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
关注 Creating Static Sites in Ruby with Rack文章,我在 Heroku 上得到一个静态站点,带有 config.ru
看起来像这样:
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
public/index.html
?
最佳答案
来自我的 previous experience带链轮、Sinatra 和 Rack::Deflater
,我很确定我只是另一个 use Rack::Deflater
远离我想要的。
我改了config.ru
对此:
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
use Rack::Deflater
run lambda # ...same as in the question
$ curl -H 'Accept-Encoding: gzip' http://localhost:9292 | file -
/dev/stdin: gzip compressed data
/css
下的静态 Assets ,
/js
, 或
/images
:
$ curl -H 'Accept-Encoding: gzip' http://localhost:9292/css/bootstrap.min.css | file -
/dev/stdin: ASCII English text, with very long lines
public/index.html
但不是为了 Assets 。
config.ru
工作(注意
use Rack::Deflater
现在在
use Rack::Static
之前):
use Rack::Deflater
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
$ curl -H 'Accept-Encoding: gzip' http://localhost:9292/css/bootstrap.min.css | file -
/dev/stdin: gzip compressed data, from Unix
关于heroku - 如何为 Heroku Cedar 上的静态 Rack 站点启用 gzip 压缩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15190295/
我是一名优秀的程序员,十分优秀!