<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -133,8 +133,12 @@ module Rack::Cache
     # Invalidate POST, PUT, DELETE and all methods not understood by this cache
     # See RFC2616 13.10
     def invalidate
-      record :invalidate
       metastore.invalidate(@request, entitystore)
+    rescue Exception =&gt; e
+      log_error(e)
+      pass
+    else
+      record :invalidate
       pass
     end
 
@@ -147,18 +151,26 @@ module Rack::Cache
       if @request.no_cache? &amp;&amp; allow_reload?
         record :reload
         fetch
-      elsif entry = metastore.lookup(@request, entitystore)
-        if fresh_enough?(entry)
-          record :fresh
-          entry.headers['Age'] = entry.age.to_s
-          entry
+      else
+        begin
+          entry = metastore.lookup(@request, entitystore)
+        rescue Exception =&gt; e
+          log_error(e)
+          return pass
+        end
+        if entry
+          if fresh_enough?(entry)
+            record :fresh
+            entry.headers['Age'] = entry.age.to_s
+            entry
+          else
+            record :stale
+            validate(entry)
+          end
         else
-          record :stale
-          validate(entry)
+          record :miss
+          fetch
         end
-      else
-        record :miss
-        fetch
       end
     end
 
@@ -225,9 +237,17 @@ module Rack::Cache
 
     # Write the response to the cache.
     def store(response)
-      record :store
       metastore.store(@request, response, entitystore)
       response.headers['Age'] = response.age.to_s
+    rescue Exception =&gt; e
+      log_error(e)
+      nil
+    else
+      record :store
+    end
+
+    def log_error(exception)
+      @env['rack.errors'].write(&quot;cache error: #{exception.message}\n#{exception.backtrace.join(&quot;\n&quot;)}\n&quot;)
     end
   end
 end</diff>
      <filename>lib/rack/cache/context.rb</filename>
    </modified>
    <modified>
      <diff>@@ -746,4 +746,29 @@ describe 'Rack::Cache::Context' do
       response['X-Response-Count'].should.equal '3'
     end
   end
+
+  it 'passes if there was a metastore exception' do
+    respond_with 200, 'Cache-Control' =&gt; 'max-age=10000' do |req,res|
+      res.body = ['Hello World']
+    end
+
+    get '/'
+    response.should.be.ok
+    response.body.should.equal 'Hello World'
+    cache.trace.should.include :store
+
+    get '/' do |cache|
+      cache.meta_def(:metastore) { raise Timeout::Error }
+    end
+    response.should.be.ok
+    response.body.should.equal 'Hello World'
+    cache.trace.should.include :pass
+
+    post '/' do |cache|
+      cache.meta_def(:metastore) { raise Timeout::Error }
+    end
+    response.should.be.ok
+    response.body.should.equal 'Hello World'
+    cache.trace.should.include :pass
+  end
 end</diff>
      <filename>test/context_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e51b1fbee7e4cf3e8a8348a0dc9f96d6b9373d5b</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </author>
  <url>http://github.com/rtomayko/rack-cache/commit/7bcd0cec2723b91ee0d557153134d457219895ba</url>
  <id>7bcd0cec2723b91ee0d557153134d457219895ba</id>
  <committed-date>2009-09-25T11:44:08-07:00</committed-date>
  <authored-date>2009-09-25T11:44:08-07:00</authored-date>
  <message>Rescue from exceptions raised by the metastore and pass on the request</message>
  <tree>e0b2a6e974938b988305132281fc11afbf44463c</tree>
  <committer>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </committer>
</commit>
