Search code examples
ruby-on-railsruby-on-rails-3herokubrowser-cachecache-control

Enabling browser side caching for rails 3.1 app on heroku


I have a quite a big jpg image file and few css files, and these are not going to change for every reload but every time it is loading the full imgae instead of caching in the browser, I tried changing the config like config.action_controller.perform_caching = true etc but nothing seems to help. Is there a way to do that?


Solution

  • This worked for me in my production.rb:

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

    That is 4 weeks which I figure is good enough.