precache.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:precache_dev 作者: carlashley 项目源码 文件源码
def already_cached(self, asset_url):
        '''Checks if an item is already cached. This is indicated in the
        headers of the file being checked.'''
        try:
            req = requests.head(asset_url, headers={'user-agent': self.user_agent})  # NOQA
            if req.headers.get('Content-Type') is not None:
                # Item is not in cache
                self.log.debug('Not in cache: %s' % asset_url)
                return False
            else:
                # Item is already cached
                self.log.info('Already in cache: %s' % asset_url)
                return True
        except:
            # In case there is an error, we should return false anyway as there
            # is no harm in re-downloading the item if it's already downloaded.
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号