Created
November 2, 2008 20:48
-
-
Save rtomayko/21747 to your computer and use it in GitHub Desktop.
tomayko.com Rack::Cache configuration
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
# 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