Skip to content

Commit

Permalink
Enable cache by default
Browse files Browse the repository at this point in the history
  • Loading branch information
prncc committed Jun 10, 2017
1 parent 99e5f06 commit 5eaac09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions steam/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def _get_request_path(self, spider, request):

class CircumventAgeCheckMiddleware(RedirectMiddleware):
def _redirect(self, redirected, request, spider, reason):
if not self.is_age_check_url(redirected.url):
# Only overrule the default redirect behavior
# in the case of mature content checkpoints.
if not re.findall('app/(.*)/agecheck', redirected.url):
return super()._redirect(redirected, request, spider, reason)

logger.debug(f"Button-type age check triggered for {request.url}.")
Expand All @@ -32,6 +34,3 @@ def _redirect(self, redirected, request, spider, reason):
cookies={'mature_content': '1'},
meta={'dont_cache': True},
callback=spider.parse_product)

def is_age_check_url(self, url):
return True if re.findall('app/(.*)/agecheck', url) else False
2 changes: 1 addition & 1 deletion steam/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

# Enable and configure HTTP caching (disabled by default)
# See http://scrapy.readthedocs.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
HTTPCACHE_ENABLED = False
HTTPCACHE_ENABLED = True
HTTPCACHE_EXPIRATION_SECS = 0 # Never expire.
HTTPCACHE_DIR = 'httpcache'
HTTPCACHE_IGNORE_HTTP_CODES = [301, 302, 303, 306, 307, 308]
Expand Down

0 comments on commit 5eaac09

Please sign in to comment.