Created
August 7, 2010 20:01
-
-
Save lsiden/513127 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| get '/views/*' do | |
| # Get file path. if refers to a directory, try index.html | |
| path = params[:splat].first.split('/') | |
| path = File.join('views', *path) | |
| path = File.join(path, 'index.html') if File.directory?(path) | |
| logger.debug(path) | |
| # set long expiration headers | |
| one_year = 360 * 24 * 60 * 60 # a little less than a year for proxy's-sake | |
| time = Time.now + one_year | |
| time = time.to_time if time.respond_to?(:to_time) | |
| time = time.httpdate if time.respond_to?(:httpdate) | |
| response['Expires'] = time | |
| response['Cache-Control'] = "public, max-age=#{one_year}" | |
| # send actual file | |
| send_file(path) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment