Skip to content

Instantly share code, notes, and snippets.

@rtomayko
Created November 2, 2008 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtomayko/21747 to your computer and use it in GitHub Desktop.
Save rtomayko/21747 to your computer and use it in GitHub Desktop.
tomayko.com Rack::Cache configuration
# from tomayko.com.ru (rackup file)
# tomayko.com Rack::Cache configuration
use Rack::Cache do
# add never-expire headers to responses that have a cache breaking slug
import 'rack/cache/config/busters'
set :metastore, "file:cache/meta"
set :entitystore, "file:cache/body"
on :receive do
if request.header?('Authorization')
request.env.delete('HTTP_IF_MODIFIED_SINCE')
request.env.delete('HTTP_IF_NONE_MATCH')
pass!
end
end
on :fetch do
next if response.freshness_information?
case request.url
when /\/feed$/
trace 'feed will expire in fifteen minutes'
response.ttl = 15 * 60
when /\/topics\/.*/, /\/circa\/.*/
trace 'topic/circa index page will expire in five minutes'
response.ttl = 5 * 60
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment