Class: Olelo::Middleware::StaticCache
- Defined in:
- lib/olelo/middleware/static_cache.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ StaticCache
constructor
A new instance of StaticCache.
Constructor Details
#initialize(app) ⇒ StaticCache
4 5 6 |
# File 'lib/olelo/middleware/static_cache.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/olelo/middleware/static_cache.rb', line 8 def call(env) # Add a cache-control header if asset is static with version string if env['PATH_INFO'].sub!(%r{^/static-\w+/}, '/static/') status, headers, body = @app.call(env) headers['Cache-Control'] = 'public, max-age=31536000' [status, headers, body] else @app.call(env) end end |