Class: HerokuDeflater::CacheControlManager
- Inherits:
-
Object
- Object
- HerokuDeflater::CacheControlManager
- Defined in:
- lib/heroku-deflater/cache_control_manager.rb
Constant Summary collapse
- DEFAULT_MAX_AGE =
'86400'.freeze
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#max_age ⇒ Object
readonly
Returns the value of attribute max_age.
Instance Method Summary collapse
- #cache_control_headers ⇒ Object
-
#initialize(app) ⇒ CacheControlManager
constructor
A new instance of CacheControlManager.
- #setup_max_age(max_age) ⇒ Object
Constructor Details
#initialize(app) ⇒ CacheControlManager
Returns a new instance of CacheControlManager.
6 7 8 9 |
# File 'lib/heroku-deflater/cache_control_manager.rb', line 6 def initialize(app) @app = app @max_age = DEFAULT_MAX_AGE end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/heroku-deflater/cache_control_manager.rb', line 4 def app @app end |
#max_age ⇒ Object (readonly)
Returns the value of attribute max_age.
4 5 6 |
# File 'lib/heroku-deflater/cache_control_manager.rb', line 4 def max_age @max_age end |
Instance Method Details
#cache_control_headers ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/heroku-deflater/cache_control_manager.rb', line 15 def cache_control_headers if HerokuDeflater.rails_version_5? headers = app.config.public_file_server.headers ||= {} headers['Cache-Control'] ||= "public, max-age=#{max_age}" headers else app.config.static_cache_control ||= "public, max-age=#{max_age}" end end |
#setup_max_age(max_age) ⇒ Object
11 12 13 |
# File 'lib/heroku-deflater/cache_control_manager.rb', line 11 def setup_max_age(max_age) @max_age = max_age end |