Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set cache control headers

  • Loading branch information...
commit 59bda788d8054478dab4cce60ae43f60931cf505 1 parent 61b4f50
@peteog authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/sinatra/simple_assets.rb
View
17 lib/sinatra/simple_assets.rb
@@ -115,6 +115,10 @@ def precompile
bundle.compile
end
end
+
+ def bundle_exists?(bundle)
+ @hashes[bundle]
+ end
end
def assets(&block)
@@ -133,13 +137,16 @@ def self.registered(app)
end
def serve_content(bundle, type)
- content = settings.assets.content_for(bundle)
- not_found unless content
+ assets = settings.assets
+ exists = assets.bundle_exists?(bundle)
- content_type type
- content
+ etag bundle if exists
+ not_found unless exists
- #TODO set cache headers
+ cache_control :public, :must_revalidate, :max_age => 86400
+
+ content_type type
+ assets.content_for(bundle)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.