Created
May 30, 2011 16:32
-
-
Save rkh/999120 to your computer and use it in GitHub Desktop.
Sinatra Stylesheet Expires
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# avoid path traversal attacks and speed up look-up | |
set :css_files, {} | |
Dir.glob("#{settings.public}/css/*.css") { |file| settings.css_files[File.basename(file, '.css')] = file } | |
get "/css/:name.css" do |name| | |
expires 60*60*24*356*3 | |
send_file setting.css_files[name] | |
end |
doh!
Thanks rkh and also cactus! :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, I intentionally avoided that to not confuse ppl new to Ruby.