在heroku上为rails 3.1 app启用浏览器端缓存

n00*_*00b 8 ruby-on-rails heroku cache-control browser-cache ruby-on-rails-3

我有一个相当大的jpg图像文件和几个css文件,这些不会改变每次重新加载,但每次它加载完整的imgae而不是在浏览器中缓存,我尝试更改配置,如config.action_controller. perform_caching = true等但似乎没有任何帮助.有没有办法做到这一点?

Wil*_*elm 7

这在我的production.rb中对我有用:

config.serve_static_assets = true
config.static_cache_control = "public, max-age=2419200"
Run Code Online (Sandbox Code Playgroud)

这是4周,我认为这是足够好的.

  • 为了避免需要记住多少2419200秒,可以使用ActiveSupport:``config.static_cache_control ="public,max-age =#{1.month.to_i}"`` (2认同)