Created
April 16, 2009 21:16
-
-
Save rtomayko/96663 to your computer and use it in GitHub Desktop.
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
class CachePolicy < Sinatra::Base | |
# always forward the request downstream immediately (before processing routes) | |
before { forward } | |
# anything with a cache breaking timestamp gets an insanely long max-age | |
get '/public/*' do | |
pass unless request.query_string =~ /^\d+$/ | |
response['Cache-Control'] = 'public, max-age=1000000000' | |
end | |
# PNGs get a 5 minute ttl | |
get '/public/*.png' do | |
response['Cache-Control'] = 'public, max-age=300' | |
end | |
# everything else is private | |
get '/*' do | |
response['Cache-Control'] = 'private' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment