有没有办法我可以记录python" requests-cache"点击缓存?

时间:2017-12-06 01:37:12

标签: python python-requests

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

1 个答案:

答案 0 :(得分:3)

根据源代码,响应对象应该设置.from_cache flag

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