简体   繁体   English

当python“ requests-cache”命中缓存时,有什么方法可以记录?

[英]Is there a way I can log when python “requests-cache” hits the cache?

我正在使用https://requests-cache.readthedocs.io/en/latest/index.html ,我想知道何时缓存缓存与网络缓存。

According to the source code, there should be a .from_cache flag set on the response object: 根据源代码,应在响应对象上设置一个.from_cache标志

In [1]: import requests

In [2]: import requests_cache

In [3]: requests_cache.install_cache('demo_cache')

In [4]: requests.get("https://stackoverflow.com").from_cache
Out[4]: False

In [5]: requests.get("https://stackoverflow.com").from_cache
Out[5]: True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM