Skip to content

Instantly share code, notes, and snippets.

@dsully
Created December 5, 2016 20:58
Show Gist options
  • Save dsully/44ec800f09fbb71bd9a1f9a7df293283 to your computer and use it in GitHub Desktop.
Save dsully/44ec800f09fbb71bd9a1f9a7df293283 to your computer and use it in GitHub Desktop.
class ConnectionRefusedCacheControlAdapter(CacheControlAdapter):
def send(self, request, **kw):
try:
resp = super(ConnectionRefusedCacheControlAdapter, self).send(request, **kw)
except Exception as e:
cache_url = self.controller.cache_url(request.url)
cache_data = self.controller.cache.get(cache_url)
cached_response = self.controller.serializer.loads(request, cache_data)
return self.build_response(request, cached_response, from_cache=True)
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment