8

我有一个相当大的jpg图像文件和很少的css文件,并且这些不会为每次重新加载而改变,但每次加载完整imgae而不是缓存时浏览器,我试着改变config.action_controller.perform_caching = true等配置,但似乎没有任何帮助。有没有办法做到这一点?在heroku上启用浏览器端缓存for rails 3.1应用程序

+0

我很想为此回答这个问题:( – imjp

+0

添加一些赏金..^_^ – n00b

+0

我想我已经在我的应用中添加了缓存。请阅读以下内容:http://devcenter.heroku.com/文章/ building-a-rails-3-application-with-the-memcache-addon 我不确定它是否是浏览器缓存,但是它正在缓存我的静态文件! – imjp

回答

7

这在我production.rb工作对我来说:

config.serve_static_assets = true 
config.static_cache_control = "public, max-age=2419200" 

这为4周,我的身影是不够好。

+2

为了避免需要记住多少确切是2419200秒,可以使用ActiveSupport:''config.static_cache_control =“public,max-age =#{1.month.to_i}”''' –

相关问题