Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

httpcache: don't store already cached response.

Rolando Espinoza La fuente503fdf39fe64
diff --git a/scrapy/contrib/downloadermiddleware/httpcache.py b/scrapy/contrib/downloadermiddleware/httpcache.py
index 045a1b2d0..a3bae921c 100644
--- a/scrapy/contrib/downloadermiddleware/httpcache.py
+++ b/scrapy/contrib/downloadermiddleware/httpcache.py
@@ -52,7 +52,9 @@ class HttpCacheMiddleware(object):
raise IgnoreRequest("Ignored request not in cache: %s" % request)
def process_response(self, request, response, spider):
- if self.is_cacheable(request) and self.is_cacheable_response(response):
+ if (self.is_cacheable(request)
+ and self.is_cacheable_response(response)
+ and 'cached' not in response.flags):
self.storage.store_response(spider, request, response)
stats.inc_value('httpcache/store', spider=spider)
return response