Search code examples
ruby-on-railsherokucache-control

Rails 5 cache control doesn't work in heroku


I am setting up the CDN in my application, and by setting the cache-control according to the new standards in Rails 5:

config.public_file_server.headers = {
    'Cache-Control' => 'public, max-age = 31536000',
    'Expires' => "# {1.year.from_now.to_formatted_s (: rfc822)}"
}

But when I'm deploying the application to Heroku, it indicates that I am not using the new standards:

DEPRECATION WARNING: config.static_cache_control is deprecated and will be removed in Rails 5.1. Please use config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=604800' } instead. (called from at /app/config/application.rb:14)

And when I view the page response headers not being applied cache-control to set

Image link


Solution

  • I found the solution on this issue https://github.com/romanbsd/heroku-deflater/issues/26, the problem was with the gem heroku deflater