class HerokuDeflater::CacheControlManager
Constants
- DEFAULT_MAX_AGE
Attributes
app[R]
max_age[R]
Public Class Methods
new(app)
click to toggle source
# File lib/heroku-deflater/cache_control_manager.rb, line 6 def initialize(app) @app = app @max_age = DEFAULT_MAX_AGE end
Public Instance Methods
cache_control_headers()
click to toggle source
# File lib/heroku-deflater/cache_control_manager.rb, line 21 def cache_control_headers if rails_version_5? { 'Cache-Control' => cache_control } else cache_control end end
setup_max_age(max_age)
click to toggle source
# File lib/heroku-deflater/cache_control_manager.rb, line 11 def setup_max_age(max_age) @max_age = max_age if rails_version_5? app.config.public_file_server.headers ||= {} app.config.public_file_server.headers['Cache-Control'] = cache_control else app.config.static_cache_control = cache_control end end
Private Instance Methods
cache_control()
click to toggle source
# File lib/heroku-deflater/cache_control_manager.rb, line 35 def cache_control @_cache_control ||= "public, max-age=#{max_age}" end
rails_version_5?()
click to toggle source
# File lib/heroku-deflater/cache_control_manager.rb, line 31 def rails_version_5? Rails::VERSION::MAJOR >= 5 end